If I access an object via another object, do I still need to represent this as aggregation (or composition) in UML diagrams? For example, if a Garage has a Car, and a Car has an Engine, If Garage accesses Engine using Car.Engine, does Garage need to include Engine and Car, or only Car ? I don't want needless associations cluttering the diagrams, so hopefully Garage can just include Car. Thanks.
Asked
Active
Viewed 36 times
0
-
That's great. Thank you. – Michael Roberts Jun 17 '19 at 16:49
-
1In a word: no. You do not need to include `Engine` in your `Garage`. All members of a class should only reside within that class's diagram. – Zephyr Jun 17 '19 at 16:49
-
1look at https://stackoverflow.com/questions/9640885/uml-aggregation-vs-association and https://stackoverflow.com/questions/29220051/is-this-an-aggregation?r=SearchResults&s=6|56.8506 – bruno Jun 17 '19 at 16:53
1 Answers
1
No, Garage would not need any association to Engine, because it is not directly associated with it.
If you really want to emphasize that Garage uses Engine, you can draw a general association ("-->") between them, but aggregation or composition would be wrong here.

Alex
- 66
- 4
-
1Instead of a general association, I think a dependency (dashed arrow), perhaps stereotyped as ≪use≫, would be more appropriate. But you are right, the diagram can do without it. – www.admiraalit.nl Jun 18 '19 at 11:37