Previous Table of Contents Next


11.3.2 Class


   A class describes a set of objects that share the same specifications of features, constraints, and semantics. Constructs::Class merges the definition of Basic::Class with Constructs::Classifier.

   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.

   Generalizations

   • “Classifier? on page 127.

   Attributes

   • isAbstract : Boolean This redefines the corresponding attributes in Basic::Class and Abstractions::Classifier.

   Associations

   • ownedAttribute : Property [*]

   The attributes (i.e., the properties) owned by the class. This is an ordered association. Subsets Classifier::attribute and

   Namespace::ownedMember.

   • ownedOperation : Operation [*]

   The operations owned by the class. This is an ordered association. Subsets Classifier::feature and

   Namespace::ownedMember.

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

   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.

   Notation

   A class is shown using the classifier symbol. As class is the most widely used classifier, the word “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

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

Window

+ size: Area = (100, 100)

# visibility: Boolean = true + defaultSize: Rectangle - xWin: XWindow

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


Figure 11.13 - 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)