Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When are IsRoot, IsAbstract & IsLeaf in UML used?

Tags:

uml

I came across the following description of IsRoot, IsAbstract & IsLeaf however do not understand when you would used them.

Excerpt from http://www2.sys-con.com/itsg/virtualcd/dotnet/archives/0108/clark/index.htm:

By checking the IsRoot check box, you are restricting the class from inheriting from other classes. Checking IsAbstract restricts the class from being instantiated, and forces clients to instantiate a derived class to access the functionality of the class. Checking IsLeaf indicates that the class is sealed. Sealed classes are noninheritable and help to limit the depth of an inheritance chain.

My understanding

  1. IsRoot seems to suggest that it is a superclass
  2. IsAbstract seems to suggest it is an abstract class
  3. IsLeaf is a class that cannot be inherited but can be instantiated.

Can someone give me a real-world example of a model that uses these? For example I can imagine class such as 'car' that is a superclass and is abstract and beneath it you would have classes such as 'Volvo', 'Chevrolet', etc.

like image 950
PeanutsMonkey Avatar asked Aug 07 '13 00:08

PeanutsMonkey


2 Answers

  • isRoot no longer exists in UML2. In UML 1 it means (from the specification) :

isRoot: Specifies whether the GeneralizableElement is a root GeneralizableElement with no ancestors. True indicates that it may not have ancestors, false indicates that it may have ancestors (whether or not it actually has any ancestors at the moment).

  • isAbstract means that the element is incomplete and cannot be instantiated.

If true, the Classifier does not provide a complete declaration and can typically not be instantiated. An abstract classifier is intended to be used by other classifiers (e.g., as the target of general metarelationships or generalization relationships). Default value is false.

  • isLeaf means that you cannot redefine the element, same as final in some programming languages.

Indicates whether it is possible to further redefine a RedefinableElement. If the value is true, then it is not possible to further redefine the RedefinableElement. Default value is false.

like image 163
Xaelis Avatar answered Sep 19 '22 02:09

Xaelis


Not real-life examples, but links to some.

  1. isRoot: I think this is no longer part of UML. That article is from 2004, which was around the time UML 2 came out, and I doubt Visio supported it. It still may not support it.
  2. isAbstract: it's a good idea to make all superclasses abstract so that you cannot create an instance that is not a member of the subclasses. Classes are essentially sets of instances. What does it mean for an instance to be a member of a superset and none of the subsets? It's unclear exactly what the classification of such an instance is, and it may inadvertently change over time. It's also a good idea to make the subclasses disjoint (non-overlapping) and covering (all known subclasses specified). There's more details and a real-life example of this using Avians in Lahman's book.
  3. isLeaf: essentially keeps people from overriding your code. I can't verify this quotation, but supposedly the The Unified Modeling Language Reference Manual says:

    Being a leaf or being constrained to be a leaf are not fundamental semantic properties but rather software engineering mechanisms to control human behavior.

Does that help?

like image 26
Jim L. Avatar answered Sep 21 '22 02:09

Jim L.