Study Cards on visibilitykind, literals, enumeration

In Fig. 6.5, we show some sample enumerations.

Can you find them?


A common enumeration, that of TrafficLightColor is shown in both a US and UK style.

UML uses the VisibilityKind to identify the visibility of attributes and operations.

The EbookKind is a useful library domain enumeration for electronic books.

The standard name for the compartment showing the enumeration literals is “literals.”
Report
What is the note attached to the VisibilityKind?
The note attached to the VisibilityKind indicates the standard symbols used in UML to identify the visibility of the feature.

In a class diagram, a member, i.e., an attribute or operation, would be preceded by one of the listed symbols to indicate the visibility
Report
What is the VisibilityKind :  Public   +

The member value/behavior may be seen or invoked by anyone
Report
What is the VisibilityKind :  Private  -
The member is accessible only from within an instance of the class
Report
What is the VisibilityKind :  Protected   #

Private, but instances of specializations of the class can also access
Report
What is the VisibilityKind :  Package   ~
Private, but peer elements in the same package can also access
Report
What is the VisibilityKind indicator?
The VisibilityKind indicator is an example of an adornment for attributes or operations.



In the UML specification, all the enumeration type names end with “Kind,” such as shown with VisibilityKind in Fig. 6.5.

We followed that reasonable convention with our own enumerations, but you may follow your own approach if you want.

In the figure, we included both TrafficLightColorKind and TrafficLightColourKind, to support both US and UK style traffic signals.
Report
Enumeration literals have identity only within the...?
Enumeration literals have identity only within the enumeration.
Report
Enumeration literals have identity only within the enumeration.

How can you test equality between two values?   
If you tried to test for equality between both the traffic light Green values, you may or may not get them to show as equal, or you might just receive a type error.

If you wish to refer to each color independently, you use the “.” naming scope operator, as shown below.

 
Report
Enumerations can participate in generalizations.


Examine Fig. 6.6. How many literals does the
DirectionalTrafficLightColor have?

 
Six, as there are three inherited values (green, yellow, and red).
Report
What is the internal representation of enumeration literals?
We do not worry about the internal representation of the enumeration literals.

They could be strings, integers starting with one, or integers starting with zero, or something else.

Some tools may allow you to specify values or an order to the literals for code generation, but that is not part of current UML.
Report
  • A unique study and practice tool
  • Never study anything twice again
  • Get the grades you hope for
  • 100% sure, 100% understanding
Remember faster, study better. Scientifically proven.
Trustpilot Logo
  • Higher grades + faster learning
  • Never study anything twice
  • 100% sure, 100% understanding
Discover Study Smart