Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Differences between Composite structure and component diagram

Tags:

uml

diagram

Good day!

I'm doing some work on composite structure diagram(CSD) and I can't figure out differences between CSD and component diagram. Both look same to me. Or am I wrong?

Could I model all situations with CSD that I can with component diagram? If not, which are the cases?

When it's better to use CSD over component diagram? (Vice versa)

Component diagram is intended to model architecture. Can't I model same architecture with CSD?

Thanks!

like image 919
simon77 Avatar asked Nov 07 '25 16:11

simon77


2 Answers

UML does not strictly define the various diagram types ("the boundaries between the various kinds of diagram types are not strictly enforced"). In general however, it is a good practice to create diagrams that present only one view on the subject.

Suppose you have a component 'Car', component 'Wheel' and component 'Engine'. The Engine drives the front wheels, not the back wheels.

Component diagrams show components and their relationships. A component is a special kind of class. The diagram does not show component instances. In the example, we would show three components. Car has a 1:4 composition association with Wheel and 1:1 composition association with Engine. Engine has a 1:2 association with Wheel. It is not trivial to specify that the engine is only connected to front wheels and that both wheels must belong to the same car. You will need to write some OCL constraints for that.

Composite structure diagrams show the component instances contained within another component and the links between these instances (in fact, I should use the word part instead of instance). This diagram shows the Engine and the four Wheels as separate blocks inside the Car component. Now it is easy to show how the Engine is only connected to the front Wheels of the same car.

like image 101
www.admiraalit.nl Avatar answered Nov 10 '25 12:11

www.admiraalit.nl


Actually most of all UML diagrams are alike (except SDs and Timing Ds) and you are allowed to put in whatever you like. It is more sort of a convention to use certain subsets in certain diagrams but there is no restriction (except see above).

Annex A of Superstructures (2.5) states:

A UML model consists of elements such as packages, classes, and associations. The corresponding UML diagrams are graphical representations of parts of the UML model.

...

NOTE. This taxonomy provides a logical organization for the various major kinds of diagrams. However, it does not preclude mixing different kinds of diagram types, as one might do when one combines structural and behavioral elements (e.g., showing a state machine nested inside an internal structure). Consequently, the boundaries between the various kinds of diagram types are not strictly enforced.

like image 34
qwerty_so Avatar answered Nov 10 '25 13:11

qwerty_so



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!