Search code examples
umlclass-diagramenterprise-architectclass-visibility

Can class visibility be shown on UML class diagrams?


Class visibility is an important part of object design. I have not seen any example diagrams showing non-public classes in several UML books, nor have I seen a way to show class visibility in Enterprise Architect, among other tools. Enterprise Architect and other tools allow you to set the class visibility in the metamodel, but I have yet to see a way to show this in the diagrams.


Solution

  • According to the UML spec v2.5 beta 2 not only the NamedElement but also the PackageableElement has the attribute Visibility of type VisibilityKind

    from p48:

    PackageableElement [Abstract Class]

    ..[snip]..

    Attributes

    • visibility : VisibilityKind [0..1] = public A PackageableElement must have a visibility specified if it is owned by a Namespace. The default visibility is public.

    Constraints

    • namespace_needs_visibility A PackageableElement owned by a Namespace must have a visibility. inv: visibility = null implies namespace = null

    I haven't found any notation guidelines for this visibility however