Previous | UML Classes | Table of Contents | UML Packages | Next |
A class describes a set of objects that share the same specifications of features, constraints, and semantics.
•
Classifier (from Kernel , Dependencies , PowerTypes ) on page 51
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.
No additional attributes
• 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.
No additional constraints
[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)))
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.
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.
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.
• Center class name in boldface.
• Capitalize the first letter of class names (if the character set supports uppercase).
• Left justify attributes and operations in plain face.
• Begin attribute and operation names with a lowercase letter.
• Put the class name in italics if the class is abstract.
• Show full attributes and operations when needed and suppress them in other contexts or when merely referring to a class.
Window+ size: Area = (100, 100) # visibility: Boolean = true + defaultSize: Rectangle - xWin: XWindowdisplay() hide() - attachX(xWin: XWindow) |
|||||
Figure 7.28 - Class notation: details suppressed, analysis-level details, implementation-level details
Windowpublic size: Area = (100, 100) defaultSize: Rectangle protected visibility: Boolean = true private xWin: XWindowpublic display() hide() private |
|||||
attachX(xWin: XWindow)