-2

So I have the following case. I have an interface A and an implementation AImpl. Now I have another implementation of A, called A2Impl, which references any instance of A besides implementing A already.

So I have now drawn the following UML class diagram:

enter image description here

Would this be correct? How do i draws this correctly?

closed as unclear what you're asking by gnat, Jörg W Mittag, BobDalgleish, Kain0_0, 8bittree Jun 6 at 14:39

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Which UML notation are you implementing? Implement, extends and composition are drawn with different line styles and arrows. – Laiv Jun 5 at 9:43
  • i am using whatever is on the english wikipedia article for class diagrams – Marcel Jun 5 at 9:50
  • Well, the answer to the question is yes you can draw such a relationship between A, AImpl and A2Impl but for the sake of the "readability" do use the proper notation to represent the different kinds of associations. – Laiv Jun 5 at 9:56
  • So, I took a look at this: en.m.wikipedia.org/wiki/Class_diagram – Marcel Jun 5 at 10:00
  • Check the first image in "Relationships". – Marcel Jun 5 at 10:01
3

Yes, it is correct, but not optimal.

The dependency just says 'A2Impl' cannot do without 'A', but that is obvious, since A2Impl implements A. In fact, the 'implements' relationship implies the dependency.

If A2Impl has a permanent reference to another instance of A, it would be better to replace the dependency by an association (an arrow with a solid line instead of a dashed line). You may wish to add multiplicities to the association (not mandatory). In the figure below, I have specified multiplicity "1" to indicate that every instance of A2Impl always refers to exactly one instance of A.

cd

If you think an association is not appropriate, you could also assign a stereotype to the dependency, to indicate the type of dependency, e.g. «call».

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