Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UML : Internal class in a class diagram

In a class diagram, is there a way of specifying that a class is an internal class of another class ?

Or is it considered as a pure implementation choice ?

like image 853
Barth Avatar asked Oct 27 '08 15:10

Barth


People also ask

How do you show a class within a class in UML?

Per UML 1.4. 2 a declaring (nesting) class and a nested class could be shown connected by a line, with an "anchor" icon on the end connected to the declaring class. An anchor icon is a cross inside a circle.

How do you represent inner classes in UML?

Inner (nested) classes are represented in UML with an association adorned with a crossed circle, as shown in Figure 3-21.

Do you put the main class in a UML diagram?

I would recommend you to use the class with main method only to init your application. In this case you don't need to include it into your diagram. But if the class that contains the main method is also part of the your application, the answer is yes you should do it.

What is contained in a UML diagram for a class?

In software engineering, a class diagram in the Unified Modeling Language (UML) is a type of static structure diagram that describes the structure of a system by showing the system's classes, their attributes, operations (or methods), and the relationships among objects.


3 Answers

Consider using a nesting relationship (a line with a '+' in a circle at the parent end).

like image 178
chimp Avatar answered Oct 06 '22 10:10

chimp


Since UML isn't supposed to be directly implementation specific, I'd use a naming convention, such as:

OuterClass vs OuterClass::InnerClass

I would imagine if you're hoping to reverse-engineer or code-generate to/from UML that different tools would us different techniques (if they support it at all).

A quick test of some reverse engineering using Enterprise Architect (EA v7) confirms that they use the above InnerClass::OuterClass syntax when processing some C# with a public inner class.

like image 37
Ray Hayes Avatar answered Oct 06 '22 10:10

Ray Hayes


For this kind of thing you have separate Diagrams showing the internal structure or processing of a class.

usually, those extra diagrams are activity diagrams to show processing. Sometimes one per method. You might also have an internal sequence diagram showing the API interactions.

No reason you can't have an additional class diagram to show internal structure of a class.

like image 29
S.Lott Avatar answered Oct 06 '22 10:10

S.Lott