My question is about an "edge case" of the UML class diagram. In particular, I have loads (about 30) classes that implement an interface. They can be split into two groups of similar classes. Within each group the classes only differ by the implementation of the methods from the interface, however they represent fundamental different problems (different partial differential equations). Since they are so similar, I figured I could "stack" them on top of each other and clarify the idea with a note.

Sure, I could also create only two classes (one for each group) and pass the implementation of the function at instantiation. However, I think that this is even worse than the current representation. Also, this would not be practical, since I expect to instantiate 100 and more objects of one class.

What do you think about the current state of the class diagram in the picture? Do you have any other ideas? Any help is welcome!

enter image description here

  • 1
    Also, this would not be practical, since I expect to instantiate 100 and more objects of one class. -- Just on that note - UML Class diagrams do not show instances/objects, so the number of instances of a class is irrelevant. – Ben Cottrell Apr 13 at 14:48
  • @Ben Cottrell thanks for the comment. I do know that, I meant that it is not practical when actually writing the code. – Isotope Apr 13 at 15:10
  • 1
    Actually my brain is bit misty so I don't get the reason behind it (maybe tomorrow), but the way you take is reasonable. Generics seem to be what you're after (what my brain seems to see). N.B.: The note link is no directed association but a dashed line with no arrow. – qwerty_so Apr 13 at 20:42
  • @qwerty_so I appreciate your comment. My goal is to create a diagram that anyone can understand, even if they are not necessarily using the software. And yes, those arrows are wrong, I have updated the picture. – Isotope Apr 14 at 6:22
  • 1
    Have you thought about the Factory pattern? – qwerty_so Apr 14 at 11:55

Obviously, your diagram can't be used as input for a code generator, but if it is intended for communication with a human audience it appears to do its job.

The "stacked" notation is used in more places in UML to indicate multiple (near) copies and the note clearly indicates how those classes differ from each other, under the assumption that your audience knows what PDE's are and how they differ. But that assumption can not be taken away by drawing the class diagram differently.

| improve this answer | |
  • As you interpreted correctly, the diagram should only convey the inner workings of the software, generating code is not intended. Do you have any further references at hand, where this stacked notation is also used? – Isotope Apr 14 at 11:16
  • 1
    @Isotope, no, I don't have any references at hand. The stacked notation may have been an UML 1 notation, and I only have UML 2 reference works here. – Bart van Ingen Schenau Apr 14 at 12:16

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.