Previous UML Classes Table of Contents UML Packages Next


7.3.7 Class

Kernel


   A class describes a set of objects that share the same specifications of features, constraints, and semantics.

*Generalizations

   

    Classifier (from Kernel , Dependencies , PowerTypes ) on page 51

*Description

   Class is a kind of classifier whose features are attributes and operations. Attributes of a class are represented by instances of Property that are owned by the class. Some of these attributes may represent the navigable ends of binary associations.

*Attributes

   No additional attributes

*Associations

   • nestedClassifier: Classifier [*] References all the Classifiers that are defined (nested) within the Class. Subsets

   Element::ownedMember

   • ownedAttribute : Property [*] The attributes (i.e., the properties) owned by the class. The association is ordered. Subsets Classifier::attribute and Namespace ::ownedMember

   • ownedOperation : Operation [*] The operations owned by the class. The association is ordered. Subsets Classifier::feature and Namespace ::ownedMember

   • / superClass : Class [*] This gives the superclasses of a class. It redefines Classifier::general. This is derived.

*Constraints

   No additional constraints

*Additional Operations

   [1] The inherit operation is overridden to exclude redefined properties.

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

   inherit = inhs->excluding(inh |

   ownedMember->select(oclIsKindOf(RedefinableElement ))->select(redefinedElement->includes(inh)))

*Semantics

   The purpose of a class is to specify a classification of objects and to specify the features that characterize the structure and behavior of those objects.

   Objects of a class must contain values for each attribute that is a member of that class, in accordance with the characteristics of the attribute, for example its type and multiplicity.

   When an object is instantiated in a class, for every attribute of the class that has a specified default. If an initial value of the attribute is not specified explicitly for the instantiation, then the default value specification is evaluated to set the initial value of the attribute for the object.

   Operations of a class can be invoked on an object, given a particular set of substitutions for the parameters of the operation. An operation invocation may cause changes to the values of the attributes of that object. It may also return a value as a result, where a result type for the operation has been defined. Operation invocations may also cause changes in value to the attributes of other objects that can be navigated to, directly or indirectly, from the object on which the operation is invoked, to its output parameters, to objects navigable from its parameters, or to other objects in the scope of the operation’s execution. Operation invocations may also cause the creation and deletion of objects.

   Issue 4448 - Visibility constrains the actionsof methods of the class. Creation and destribution of links should be allowed by methods that have access to at least one end of the association.

   A class cannot access private fautres of another class, or protected features on another class that is not its supertype. When creating and deleting associations, at least one end must allow access to the class.

*Notation

   A class is shown using the classifier symbol. As class is the most widely used classifier, the keyword class need not be shown in guillemets above the name. A classifier symbol without a metaclass shown in guillemets indicates a class.

*Presentation Options

   A class is often shown with three compartments. The middle compartment holds a list of attributes while the bottom compartment holds a list of operations.

   Attributes or operations may be presented grouped by visibility. A visibility keyword or symbol can then be given once for multiple features with the same visibility.

   Additional compartments may be supplied to show other details, such as constraints, or to divide features.

*Style Guidelines

*Examples



Window

+ size: Area = (100, 100) # visibility: Boolean = true + defaultSize: Rectangle - xWin: XWindow

display() hide() - attachX(xWin: XWindow)


   Figure 7.28 - Class notation: details suppressed, analysis-level details, implementation-level details

Figure 7.29 - Class notation: attributes and operations grouped according to visibility

Window

public size: Area = (100, 100) defaultSize: Rectangle protected visibility: Boolean = true private xWin: XWindow

public display() hide() private


    attachX(xWin: XWindow)