In class diagrams, visibility defines whether other classes can see and use the attributes and operations of specific classes.
For example, other classes can see and use the attributes and operations in a class with public visibility, while the attributes and operations with private visibility can be seen and used only by the class that contains them.
As the following table illustrates, 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.
Visibility level | Icon for attribute | Icon for operation | Text symbol | Description |
---|---|---|---|---|
Private | ![]() |
![]() |
- | Only classes within the same container can see and use the classes with Private visibility. |
Protected | ![]() |
![]() |
# | Only classes within the same container or a descendent of the container can see and use the classes with Protected visibility. |
Public | ![]() |
![]() |
+ | Any class that can see the container can also see and use the classes with Public visibility. |
You can specify visibility styles for classifier features, including
attributes and operations in class diagrams. You can specify the
visibility styles by showing or hiding decoration icons (such as ) and text
symbols (such as #) that indicate the level of visibility for attributes
and operations.