Are there any good resources to discuss creating and using UML component diagrams?

As part of the assignment, I need to create a component diagram for existing code. I understand what a component diagram is and the information that it represents, but I'm not sure that I need to follow how to look at the code in the diagram to create a component diagram. I also do not sell on how a component diagram, if one is presented to me, will help me with the implementation of the system.

+4
source share
6 answers

Perhaps take a look at Scott Ambler UML 2 Component Diagram Guide and Introduction to UML 2 Component Diagrams . These are IMHO two good sources that explain how and when such a chart can be used.

+2
source

You indicate two separate problems: how to move from code to a diagram and how to use it as a guide for implementing the system. If you are drawing a diagram of existing code, I do not think the second question is applicable.

If you are developing new code, then a component diagram can be 1) a useful abstraction for understanding the important parts of the code, minus all the distractions and 2) a good way to communicate with others.

If you look at existing code, then the existing component diagram (or one of several other UML artifacts) can serve as a guide for the code, which especially helps in maintenance: it is easier to locate errors, the main responsibilities of the class, etc.

If there is no diagram, then doing this by reading the code is a good way to get to know each other. I did this in a number of cases when inheriting a complex code base. As a result, I have a couple of pages of application diagrams and databases that tell me at first glance interesting things about its main components. At any time, I will be well acquainted with some areas, and not with others, depending on what I'm working on. Charts are a good reminder of how to use the various parts of the application. And they are useful in bringing others to the team; they understand the code much faster after an hour and a half walk on the chart.

To work with existing code, you will need to read it, identify the main classes used and go back to understand the dependencies and interfaces, method signatures and data structures that they use to work together. If this is a database-enabled application, it may be useful to see a description of the database, as it should reflect the main problems of the application.

This helps to have some use cases to guide the investigation, as in event-driven applications, you need to understand what the user does to track the code. If there are no existing use cases, start by writing some simple high-level ones. Then go through the code for the used case and identify the main objects used. We hope you find the main classes in the program to determine the main use cases you use. For example, if the application is an e-commerce web application with an administrative user interface, then you will identify a number of end-user and administrative-user use cases and should expect to see some classes specific to each of these families, as well as general and utility classes. used everywhere.

Stay at a high level, avoid the temptation to consider every thing that you come across.

As Pascal said, Scott Ambler is an excellent resource for practical UML knowledge and has guild lines that you can use as little or as much as you like. In particular, see Introduction to UML 2 Component Diagrams . Hover, he writes a lot more for people developing new code than those who document existing code, so you need to adapt some of what he discusses.

+2
source

Martin Fowler " UML Distilled" is still the best UML book you can get. Its main advantage is that it is thin - it is densely packed with information.

+2
source

For me, UML does not primarily help me develop a system (although it does help). It's about how to help me pass the design on to others by giving us a common language / designation.

This facilitates communication, so we do not waste time trying to transfer between our various reference systems.

+1
source
  • Scott Ambler is another good standard answer. However, in the case of component diagrams, I find sentences in the section ( Section Creating Component Diagrams ), but they are long and not related to the needs of your documentation. From Scott's list (Creating Component Diagrams) I would really focus only on (1, 4, 5, 13), since many of them are the best examples of design. I will add a few more of mine.

  • Martin Fowler's book is great in many ways, but not quite in depth for Component Diagrams or Co. Massive 7 pages showing where it was prioritized at the time of writing, since class diagrams get 18 pages or so.

  • I agree with you that you must understand when to use a UML diagram. The UML 2.2 specification itself suggests that it was created for component oriented (Service / Interface) oriented systems. Adopting a basic MVC GUI application and entering the component diagram / model does not really make sense. There are also several ways to diagram component relationships; Scott Ambler's website shows them in Figure 1. For large multiprocessor implementations, I found these diagrams to be very efficient, for example, many interfaces and many system abstractions.

My suggestions: (I often use components for modeling, and I read the UML specification on this material)

  • Skip the use of ports for the HL component diagram, they are for grouping and although they look funny in the Scott Ambler diagram, you donโ€™t get much effort.

  • Avoid getting into the internal structure of the components. Only do this if clarity is required for a high level of complexity.

  • Do not insert most โ€œclassesโ€ into components.

  • Focus on interfaces and where real boundaries exist, keys are public interfaces, packet groupings, WSDL, external system interactions.

  • For your first few, I will start from top to bottom. First do one of all the external interactions of the system, then go down the next level, use the ports and the composite structure if you want, but I donโ€™t like them, they are messy because the composite structure is actually parts, a UML object, which is an instance of a class or component , naming becomes complicated, etc.

  • Choose one notation altogether, use ball and socket connections for hard communication and just switch to the use / dependency line between the component and the provider for loose communication, where you can actually switch the component (interface implementations), as Scott Ambler mix in figure 1 (see above), loose on the left and tight coupling on the right. The UML specification also mentions this in section 8 of the UML 2.2 add-in.

+1
source

From the following topic in VS 2010 Ultimate docs:

UML Component Diagrams: Recommendations : http://msdn.microsoft.com/en-us/library/dd409393%28VS.100%29.aspx

Drawing component diagrams has several advantages:

Thinking about your design with respect to the main blocks helps the development team understand the existing design and create a new one.

Considering your system as a combination of components with clearly defined provided and necessary interfaces, you improve the separation between the components. This, in turn, facilitates understanding of the design and its change when changing requirements.

Component diagram
(source: microsoft.com )

0
source

All Articles