Previous UML Classes Table of Contents UML Packages Next


7.3.8 Classifier

Kernel , Dependencies , PowerTypes


   A classifier is a classification of instances, it describes a set of instances that have features in common.

*Generalizations

   

    Namespace (from Kernel ) on page 101

   

    RedefinableElement (from Kernel ) on page 132

   

    Type (from Kernel ) on page 137

*Description

   A classifier is a namespace whose members can include features. Classifier is an abstract metaclass.

   A classifier is a type and can own generalizations, thereby making it possible to define generalization relationships to other classifiers. A classifier can specify a generalization hierarchy by referencing its general classifiers.

   A classifier is a redefinable element, meaning that it is possible to redefine nested classifiers.

*Attributes

   • isAbstract: Boolean 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.

*Associations

   Element::ownedElement

   • / inheritedMember: NamedElement [*] Specifies all elements inherited by this classifier from the general classifiers. Subsets Namespace ::member. This is derived.

Issue 8089 -Remove erroneous package association.

   • redefinedClassifier: Classifier [*] References the Classifiers that are redefined by this Classifier. Subsets

   RedefinableElement ::redefinedElement

   Package Dependencies

   • substitution : Substitution References the substitutions that are owned by this Classifier. Subsets Element::ownedElement and NamedElement ::clientDependency .)

   Package PowerTypes

   • powertypeExtent : GeneralizationSet Designates the GeneralizationSet of which the associated Classifier is a power type.

*Constraints

   [1] The general classifiers are the classifiers referenced by the generalization relationships.

   general = self.parents()

   [2] Generalization hierarchies must be directed and acyclical. A classifier cannot be both a transitively general and transitively specific classifier of the same classifier.

   not self.allParents()->includes(self)

   [3] A classifier may only specialize classifiers of a valid type.

   self.parents()->forAll(c | self.maySpecializeType(c))

   [4] The inheritedMember association is derived by inheriting the inheritable members of the parents.

   self.inheritedMember->includesAll(self.inherit(self.parents()->collect(p | p.inheritableMembers(self)))

   Package PowerTypes

   [5] The Classifier that maps to a GeneralizationSet may neither be a specific nor a general Classifier in any of the Generalization relationships defined for that GeneralizationSet . In other words, a power type may not be an instance of itself nor may its instances also be its subclasses.

*Additional Operations

   [1] The query allFeatures() gives all of the features in the namespace of the classifier. In general, through mechanisms such as inheritance, this will be a larger set than feature.

   Classifier::allFeatures(): Set(Feature);

   allFeatures = member->select(oclIsKindOf(Feature))

   [2] The query parents() gives all of the immediate ancestors of a generalized Classifier.

   Classifier::parents(): Set(Classifier);

   parents = generalization.general

   [3] The query allParents() gives all of the direct and indirect ancestors of a generalized Classifier.

   Classifier::allParents(): Set(Classifier);

   allParents = self.parents()->union(self.parents()->collect(p | p.allParents())

   [4] The query inheritableMembers() gives all of the members of a classifier that may be inherited in one of its descendants, subject to whatever visibility restrictions apply.

   Classifier::inheritableMembers(c: Classifier): Set(NamedElement );

   pre: c.allParents()->includes(self)

   inheritableMembers = member->select(m | c.hasVisibilityOf(m))

   [5] The query hasVisibilityOf() determines whether a named element is visible in the classifier. By default all are visible. It is only called when the argument is something owned by a parent.

   Classifier::hasVisibilityOf(n: NamedElement ) : Boolean;

   pre: self.allParents()->collect(c | c.member)->includes(n)

   if (self.inheritedMember->includes(n)) thenhasVisibilityOf = (n.visibility <> #private)

   else

   hasVisibilityOf = true

   [6] The query conformsTo() gives true for a classifier that defines a type that conforms to another. This is used, for example, in the specification of signature conformance for operations.

   Classifier::conformsTo(other: Classifier): Boolean;

   conformsTo = (self=other) or (self.allParents()->includes(other))

   [7] The query inherit() defines how to inherit a set of elements. Here the operation is defined to inherit them all. It is intended to be redefined in circumstances where inheritance is affected by redefinition.

   Classifier::inherit(inhs: Set(NamedElement )): Set(NamedElement );

   inherit = inhs

   [8] The query maySpecializeType() determines whether this classifier may have a generalization relationship to classifiers of the specified type. By default a classifier may specialize classifiers of the same or a more general type. It is intended to be redefined by classifiers that have different specialization constraints.

   Classifier::maySpecializeType(c : Classifier) : Boolean;

   maySpecializeType = self.oclIsKindOf(c.oclType)

*Semantics

   A classifier is a classification of instances according to their features.

   A Classifier may participate in generalization relationships with other Classifiers. An instance of a specific Classifier is also an (indirect) instance of each of the general Classifiers. Therefore, features specified for instances of the general classifier are implicitly specified for instances of the specific classifier. Any constraint applying to instances of the general classifier also applies to instances of the specific classifier.

   The specific semantics of how generalization affects each concrete subtype of Classifier varies. All instances of a classifier have values corresponding to the classifier’s attributes.

   A Classifier defines a type. Type conformance between generalizable Classifiers is defined so that a Classifier conforms to itself and to all of its ancestors in the generalization hierarchy.

   Package PowerTypes

   The notion of power type was inspired by the notion of power set. A power set is defined as a set whose instances are subsets. In essence, then, a power type is a class whose instances are subclasses. The powertypeExtent association relates a Classifier with a set of generalizations that a) have a common specific Classifier, and b) represent a collection of subsets for that class.

*Semantic Variation Points

   The precise lifecycle semantics of aggregation is a semantic variation point.

*Notation

   Classifier is an abstract model element, and so properly speaking has no notation. It is nevertheless convenient to define in one place a default notation available for any concrete subclass of Classifier for which this notation is suitable. The default notation for a classifier is a solid-outline rectangle containing the classifier’s name, and optionally with compartments separated by horizontal lines containing features or other members of the classifier. The specific type of classifier can be shown in guillemets above the name. Some specializations of Classifier have their own distinct notations.

   The name of an abstract Classifier is shown in italics.

   An attribute can be shown as a text string. The format of this string is specified in the Notation subsection of Property (from Kernel , AssociationClasses ) on page 125.

*Presentation Options

   Any compartment may be suppressed. A separator line is not drawn for a suppressed compartment. If a compartment is suppressed, no inference can be drawn about the presence or absence of elements in it. Compartment names can be used to remove ambiguity, if necessary.

   An abstract Classifier can be shown using the keyword {abstract} after or below the name of the Classifier.

   The type, visibility, default, multiplicity, property string may be suppressed from being displayed, even if there are values in the model.

   The individual properties of an attribute can be shown in columns rather than as a continuous string.

*Style Guidelines

   

   Attribute names typically begin with a lowercase letter. Multi-word names are often formed by concatenating the words and using lowercase for all letters except for upcasing the first letter of each word but the first.

   

   Center the name of the classifier in boldface.

   

   Center keyword (including stereotype names) in plain face within guillemets above the classifier name.

   

   For those languages that distinguish between uppercase and lowercase characters, capitalize names (i.e, begin them with an uppercase character).

   

   Left justify attributes and operations in plain face.

   

   Begin attribute and operation names with a lowercase letter.

   

   Show full attributes and operations when needed and suppress them in other contexts or references.

*Examples



   Figure 7.30 - Examples of attributes

   The attributes in Figure 7.30 are explained below.

   

   ClassA::name is an attribute with type String.

   

   ClassA::shape is an attribute with type Rectangle.

   

   ClassA::size is a public attribute of type Integer with multiplicity 0..1.

   

   ClassA::area is a derived attribute with type Integer. It is marked as read-only.

   

   ClassA::height is an attribute of type Integer with a default initial value of 5.

   

   ClassA::width is an attribute of type Integer.

   

   ClassB::id is an attribute that redefines ClassA::name.

   

   ClassB::shape is an attribute that redefines ClassA::shape. It has type Square, a specialization of Rectangle.

   

   ClassB::height is an attribute that redefines ClassA::height. It has a default of 7 for ClassB instances that overrides the ClassA default of 5.

   

   ClassB::width is a derived attribute that redefines ClassA::width, which is not derived.

   An attribute may also be shown using association notation, with no adornments at the tail of the arrow as shown in Figure 7.31.


   Figure 7.31 - Association-like notation for attribute

   Package PowerTypes

   For example, a Bank Account Type classifier could have a powertype association with a GeneralizationSet . This GeneralizationSet could then associate with two Generalizations where the class (i.e., general Classifier) Bank Account has two specific subclasses (i.e., Classifiers): Checking Account and Savings Account. Checking Account and Savings Account, then, are instances of the power type: Bank Account Type. In other words, Checking Account and Savings Account are both: instances of Bank Account Type, as well as subclasses of Bank Account. (For more explanation and examples, see Examples in the GeneralizationSet section, below.)