Can class visibility be displayed 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, and I have not seen a way to show class visibility in Enterprise Architect, among other tools. Enterprise Architect and other tools allow you to set class visibility in a metamodel, but I have not yet seen a way to show this in diagrams.

+8
uml class-diagram enterprise-architect class-visibility
source share
6 answers

According to UML spec v2.5 beta 2, not only NamedElement, but also PackageableElement has the VisibilityKind attribute

from p48:

PackageableElement [Abstract class]

.. [incision] ..

Attributes

  • visibility: VisibilityKind [0..1] = public. A batch Item must have the visibility specified if it belongs to a namespace. By default, visibility is public.

Limitations

  • namespace_needs_visibility The PackageableElement element that belongs to the namespace must be visible. inv: visibility = null implies namespace = null

I did not find any indication of this appearance, however

+1
source share

In Eclipse, you have visibility in the icon. I mean, you have a green class icon, and if it's closed, then p is on top. This icon also appears in the class diagram if you select an option. I hope for this help.

0
source share

UML supports visibility in a neutral programming mode, both in the metamodel and in the presentation.

There is an enumeration with the name VisbilityKind, which is used in different places (see the UML 2.3 superstructure specification , section 7.3.5.5, page 142.)

In class diagrams, there are various ways to illustrate visibility. The most common is the use of “-” to represent private functions and “+” to represent the public. For example:

---------------------------- | Class | |--------------------------| | +publicAttribute: Type | | -privateAttribute: Type | |--------------------------| | +publicMethod() | | -privateMethod() | ---------------------------- 

See figure 7.28 / 7.29 on page 52 of the specification for more details.

NTN.

0
source share

I think you need to take a look at Unidirectional and Bidirectional Communications

0
source share

I just looked it up in the UML 2.4.1 framework. Figure 10.3 s. 95 you see a class defined as a type, which is a NamedElement, which is an element. With a visibility package, a NamedElement has visibility, as defined in 9.21.1 on page 88, if it belongs to a namespace. That way, a class has visibility if you have visibility. You can use the usual notation with + - # and ~ (p. 89).

VisualParadigm can do this.

0
source share

If you define your class with a stereotype (say <<class →), you can then assign the stereotype to a shape-script. If you specify only a decoration, this should use the default drawing for the class and add your decoration, which can be conditional based on the scope property of the class:

 decoration X { if(hasproperty("scope","public")) print("P"); } 

This prints P in the upper left corner of the open class. However, you may also have an icon.

Unfortunately, I cannot find a way to assign the shape-script to the standard of a non-stereotyped class. Does anyone know how to do this?

0
source share

All Articles