How to Draw a Class Diagram with Separate Distinct Classes with Same Name?

00-class-diagram-class-name-thumbUsers are not allowed to give same name to two different UML classes when the classes are put under the same parent. It is like you cannot have two physical files with same name in same directory, or having two Java classes with same name under same package.

If you really need to draw two different classes in a class diagram but with same name, please check if you are really doing something legit. This article is written to give you some helps.


Do you Really Want Two Distinct UML Classes in Same Name?

Please see if any of the following statement describes your intention.

I want to visualize in class diagram the relationship between classes in different packages

Although you cannot create classes with same name under same parent, you are allowed to have classes in same name under different packages.

Classes with same names under different packages

Classes with same names under different packages

If what you want to do is to visualize two distinct classes that come from different packages, you can drag them onto your UML class diagram. If you want to create the classes, you have to draw the packages in class diagram (or re-use them by dragging from Diagram Navigator/Model Explorer) and draw the classes in them.

Relating classes with same name, in class diagram

Relating classes with same name, in class diagram

I want to visualize the state change of one specific class.

If you want to show in class diagram the changes of class (or a specific set of classes) throughout a period of time or stages of software development, which is pretty uncommon, you can use separate models to store the different “states” of classes, instead of putting all of them under the same package. The best solution would be to use our Visual Paradigm Teamwork Server or VPository to keep revisions for your software design. By doing so, you can use the Visual History tool to visualize the design changes.

I am building a concept model and I want a casual way to document the possible attributes set of a class in different cases

Please organize your conceptual model with multiple models or packages, and put the classes into the models and packages. After that you can visualize them in diagram without any problem.

Classes with same names under different models

Classes with same names under different models

Related Links

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply