Visibility in domain modeling class diagrams
In domain modeling class diagrams, visibility defines whether
attributes and operations of specific classes can be seen and used
by other classes.
For example, the attributes and operations in a class with public visibility can be seen and used by other classes, while the attributes and operations with private visibility can be seen and used only by the class that contains them.
You can use decoration icons or text symbols to show the level of visibility for attributes and operations. A text symbol appended to the name of an association end shows the visibility of that association end.
The following table illustrates how different levels of visibilities are represented for attributes and operations with visibility icons or text symbols in class diagrams.
Visibility level | Icon for attribute | Icon for operation | Text symbol | Description |
---|---|---|---|---|
Private | ![]() |
![]() |
- | Only classes in the same container can see and use the classes. |
Protected | ![]() |
![]() |
# | Only classes in the same container or a descendent of the container can see and use the classes. |
Public | ![]() |
![]() |
+ | Any class that can see the container can also see and use the classes. |
Package | ![]() |
![]() |
~ | Only classes within the same package as the container can see and use the classes. |