Kernel ­ the Operations Diagram

The Operations diagram of the Kernel package is shown in Figure 29.


In order to locate the metaclasses that are referenced from this diagram,
· See "BehavioralFeature (from Kernel)" on page 72.
· See "Constraint (from Kernel)" on page 54.
· See "Classifier (from Kernel, Dependencies, PowerTypes)" on page 61.
· See "Parameter (from Kernel)" on page 73.

Operation (from Kernel)

An operation is a behavioral feature of a classifier that specifies the name, type, parameters, and constraints for invoking an associated behavior.

Description

An operation is a behavioral feature of a classifier that specifies the name, type, parameters, and constraints for invoking an associated behavior.

Attributes
Associations

Constraints
]
[1] If this operation has a single return result, isOrdered equals the value of isOrdered for that parameter. Otherwise isOrdered is false.

isOrdered = if returnResult->size() = 1 then returnResult->any().isOrdered else false endif

[2] If this operation has a single return result, isUnique equals the value of isUnique for that parameter. Otherwise isUnique is true.

isUnique = if returnResult->size() = 1 then returnResult->any().isUnique else true endif

[3] If this operation has a single return result, lower equals the value of lower for that parameter. Otherwise lower is not defined.

lower = if returnResult->size() = 1 then returnResult->any().lower else Set{} endif

[4] If this operation has a single return result, upper equals the value of upper for that parameter. Otherwise upper is not defined.

upper = if returnResult->size() = 1 then returnResult->any().upper else Set{} endif

[5] If this operation has a single return result, type equals the value of type for that parameter. Otherwise type is not defined.

type = if returnResult->size() = 1 then returnResult->any().type else Set{} endif

[6] A bodyCondition can only be specified for a query operation.

bodyCondition->notEmpty() implies isQuery

Additional Operations

[1] The query isConsistentWith() specifies, for any two Operations in a context in which redefinition is possible, whether redefinition would be logically consistent. A redefining operation is consistent with a redefined operation if it has the same number of formal parameters, the same number of return results, and the type of each formal parameter and return result conforms to the type of the corresponding redefined parameter or return result.

Operation::isConsistentWith(redefinee: RedefinableElement): Boolean;
pre: redefinee.isRedefinitionContextValid(self)
    isConsistentWith = (redefinee.oclIsKindOf(Operation) and
let op: Operation = redefinee.oclAsType(Operation) in
    self.formalParameter.size() = op.formalParameter.size() and
    self.returnResult.size() = op.returnResult.size() and
    forAll(i | op.formalParameter[i].type.conformsTo(self.formalParameter[i].type)) and
    forAll(i | op.returnResult[i].type.conformsTo(self.returnResult[i].type))
)

Semantics

An operation is invoked on an instance of the classifier for which the operation is a feature.

The preconditions for an operation define conditions that must be true when the operation is invoked. These preconditions may be assumed by an implementation of this operation.

The postconditions for an operation define conditions that will be true when the invocation of the operation is completes successfully, assuming the preconditions were satisfied. These postconditions must be satisfied by any implementation of the operation.

The bodyCondition for an operation constrains the return result. The bodyCondition differs from postconditions in that the bodyCondition may be overridden when an operation is redefined, whereas postconditions can only be added during redefinition.

An operation may raise an exception during its invocation. When an exception is raised, it should not be assumed that the postconditions or bodyCondition of the operation are satisfied.

An operation may be redefined in a specialization of the featured classifier. This redefinition may specialize the types of the formal parameters or return results, add new preconditions or postconditions, add new raised exceptions, or otherwise refine the specification of the operation.

Each operation states whether or not its application will modify the state of the instance or any other element in the model (isQuery).

An operation may be owned by and in the namespace of a class that provides the context for its possible redefinition.

Semantic Variation Points

The behavior of an invocation of an operation when a precondition is not satisfied is a semantic variation point.

Notation

An operation is shown as a text string of the form:

visibility name ( parameter-list ) : property-string

· Where visibility is the operation's visibility -- visibility may be suppressed.
· Where name is the operation's name.
· Where parameter-list is a comma-separated list of formal parameters, each specified using the syntax:
direction name : type-expression [multiplicity] = default-value [{ property-string }]
· Where direction is the parameter's direction, with the default of in if absent.
· Where name is the parameter's name.
· Where type-expression identifies the type of the parameter.
· Where multiplicity is the parameter's multiplicity in square brackets -- multiplicity may be suppressed in which case [1] is assumed.
· Where default-value is a value specification for the default value of the parameter. The default value is optional (the equal sign is also omitted if the default value is omitted).
· Where property-string indicates property values that apply to the parameter. The property string is optional (the  braces are omitted if no properties are specified).
· Where property-string optionally shows other properties of the operation enclosed in braces.

Presentation Options

The parameter list can be suppressed.

Style Guidelines

An operation name typically begins with a lowercase letter.

Examples

display ()
-hide ()
+createWindow (location: Coordinates, container: Container [0..1]): Window
+toString (): String