Reputation: 45
My question is pretty straightforward. How do I represent or show encapsulation when modelling a UML class diagram? Inheritance is modelled using the arrows and an abstract class is shown by having the class name in italics or between the following arrows as shown, << Animals >> but what do you do for encapsulation?
Upvotes: 2
Views: 1905
Reputation: 3625
Each feature of a class can have a visibility. Private features make it possible to encapsulate the state of the instance. The notation for a private feature is a -
sign in front of its name (+
for public, #
for protected and ~
for package visibility).
PS: An abstract class is not shown with "arrows". Instead it is shown with the word {abstract}
in curly brackets (or as you correctly state by writing the name in italics).
PPS: "Arrows" (<<...>>) are not UML notation. You probably mean guillemets: «...». They are used to annotate language elements, that don't have a distinct notation, like DataTypes. In this case the keyword «dataType» is shown above the name. They could also be the notation for a property of a language element. For example an Activity with isSingleExecution=true
will show the keyword «singleExecution». Why this case is not expressed with curly brackets, as in the case of isAbstract=true
is shrouded in mystery. Finally they are used for user defined language elements (=stereotypes). Please note, that such elements are one level above the model elements, i.e. on the language level (also called meta level). Therefore, they don't express anything on the level of the modeled system. A stereotype «Animals» defines a new language element, but not an animal.
Upvotes: 4