1

Please consider a class diagram and a component diagram as shown below. In the class diagram I use association classes to represent the relationship between two classes (BaseLink and ShoulderLink) as well as between a class and an association class (Motor and J1). In the component diagram, I can represent properties holding instances of the classes BaseLink, ShoulderLink and Motor but not J1 and T1. Whereas J1 can still be expressed as the type of a connector between the properties base and shoulder, I see no way to express the connection between this typed connector and motor1:

For clarification: The component diagram is missing the bounding box of the surrounding component and can thus be mistaken for an object diagram.

Component Diagram and Class Diagram with AssociationClasses

I am searching for a way to represent this association class in the component diagram as well and I am looking forward to your suggestions.

3
  • 2
    I find it odd that there are so many 1:1 mappings between classes in the class diagram and components in the component diagram. Perhaps the level of abstraction in the component diagram is wrong. A component is usually made up of one or more classes and the diagram will show how sets of classes (components) relate to each other.
    – Thomas Owens
    Jul 20 at 14:22
  • 2
    This doesn't look like a component diagram, this seems to be an object diagram. In any case, there isn't necessarily a single way to translate a higher level class diagram to a lower level object diagram ("higher level" meaning "a more conceptual level", and "lower level" meaning that it's closer to implementation, and in this case specifically, to how things look at runtime). So think about how are you going to implement those association classes in actual code - then just draw that (the runtime objects and relationships between them). Jul 20 at 16:51
  • Thanks for your comments! To clarify: The depicted diagrams are intentionally simplified. The upper one is missing the bounding box of the surrounding component. This is misleading. Sorry for that! Regarding "runtime objects": The model is used in a model-to-text transformation resulting in a set of configuration files among other. The target format does not know "classes" and the like, so it is difficult and in fact undesirable (for me) to model according to the actual code.
    – hielsnoppe
    Jul 21 at 15:04
2

Indeed, as Filip rightly spotted in the comments, the upper part does not seem to show components (which are related to other components via interfaces, an do not use the : syntax for their identification), but either:

  • objects in an object diagram: objects correspond to instances of classes and objects are identified referring to their class (e.g. colon notation object name : class name)
  • internal parts of a larger component, some of them being in fact object-alike, with a colon notation. But I’d miss the enclosing component and perhaps also ports to connect some parts with the external world.

But in both case the notation and mapping are the same:

  • objects/parts are instances of classes and can be mapped to the class they instantiate (several objects could instantiate a same class)
  • links are instances of associations. They can be mapped to the association either directly using the colon notation if the association is named, or indirectly, by deduction using role names at the link end.
  • nothing is defined for association classes which are at the same time, an association and a class, and it is therefore difficult to depict them as link and as object.

There are two possibilities for an association-class A between X and Y:

  • use the same notation as for association class by analogy, linking with a doted line the association class instance :A to the link between :X and :Y.
  • use a more implementation like approach, using the association-class instance as middle object inserted into the link (i.e with a link between :X and :A and :A and :Y

The first one seems closer to the design semantics whereas the second is more explicit on the meant implementation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.