text stringlengths 16 313 |
|---|
A complete description ofthe OCL syntax and semantics can be found in [Warmer-99]. |
The following se-lected summary contains the most useful OCL syntax for creating navigation ex-pressions and Boolean conditions. |
Syntax for some common navigation expressions is shown below. |
The left-most element must be an expression for an object ora set of objects. |
The expressions are meant to work on sets of values when applica-ble. |
For more details and syntax, see the OCL description. |
The result is the value of the attribute or the related object(s). |
The result is the related object selected by the qualifier. |
Note that this syntax is applicable to array indexing as a form of qualification. |
The result is the property of the set. |
set -> select ( boolean-expression ) |
The result is the subset of objects in the set for which the Boolean expression is true. |
The set of pilots who have enough training hourscompany. |
An operation is a specification of a transformation or query that an object may becalled to execute. |
It has a name and a list of parameters. |
A method is a procedurethat implements an operation. |
It has an algorithm or procedure description. |
See also call, call event, method. |
An operation specifies a transformation on the state of the target object (and pos-sibly the state of the rest of the system reachable from the target object) or a querythat returns a value to the caller of the operation. |
An operation may be imple-mented as a a method or as a call event that causes a transition in the state ma-chine of an active object. |
An operation is invoked by a call, which suspends thecaller until the execution of the operation is complete, after which the caller re-sumes control beyond the point of the call, receiving a return value if one is sup-plied by the operation. |
An operation is declared in a class. |
The declaration is inherited by the descen-dants of the class. |
If another declaration has the same “matching signature,” it isthe same operation. |
An implementation may specify a rule for matching signa-tures to test for conflict, but by default, it includes the name of the operation andthe classes (but not the names or directions) of the parameters, not including re-turn parameters. |
The same operation can appear in a descendant class. |
In thatcase, it is treated as a repetition of the inherited declaration and ignored. |
The pur-pose is to permit an operation to be declared multiple times in classes that are de-veloped in different packages, using name matching. |
It represents the governing declaration of the operation that isinherited by the others. |
A method is the implementation of an operation (it may also be implementedby a call event). |
If an operation is declared in a class without the abstract property,then it has a method definition in the class. |
Otherwise, the operation may be ab-stract (and there is no method), or it may be concrete with an inherited method. |
An operation has the following main constituents. |
Possible values aresequential Callers must coordinate so that only one call to anobject (on any sequential operation) may execute atonce. |
If concurrent calls occur, then the semanticsand integrity of the system cannot be guaranteed. |
The others are blocked until the execution ofthe first operation is complete. |
It is the responsibil-ity of the modeler to ensure that deadlocks do notoccur because of simultaneous blocks. |
Guarded op-erations must perform correctly (or block them-selves) in the case of a simultaneous sequentialoperation, or guarded semantics cannot beclaimed. |
All of them may proceed concurrently withcorrect semantics. |
Concurrent operations must bedesigned so that they perform correctly in the caseof a concurrent, sequential, or guarded operationon the same object. |
Otherwise, concurrent seman-tics cannot be claimed. |
If false, the current implementation isinherited unchanged by all descendants. |
If false, it may alter the state of the system, but achange is not guaranteed. |
with the list of parameter types (not including parameternames or return types), is called the matching signatureof the operation. |
The matching signature must be uniquewithin the class and its ancestors. |
If there is a duplication,it is taken as a redeclaration of the operation, which mustmatch completely. |
If they match, all but the operationdeclaration in the highest ancestor are ignored. |
If they donot match, the model is ill formed. |
return type A list of the types of the values returned by a call of theoperation, if any. |
then this property has the value null. |
Note that many lan-guages do not support multiple return values, but itremains a valid modeling concept that can be imple-mented in various ways, such as by treating one or moreof the parameters as output values. |
Possible values areinstance The operation may be applied to individual objects. |
The format of the specification is not prescribedby UML and can take various forms. |
A method has the same constituents as an operation. |
In addition, it may have oneor more ofbehavior An optional state machine describing the implementationof the method. |
Usually, this would be expressed in a program-ming language, although a natural language expression ispossible for informal specifications. |
Generally, this valuewould not be supplied if the state machine is supplied. |
A call event has the same constituents as an operation. |
The implementation of theoperation must be specified by one or more transitions that have the call event as atrigger. |
An operation is shown as a text string that can be parsed into properties of the op-eration. |
The stereotype, visibility, return-type-expression, and property string are op-tional (together with their delimiters). |
The parameter list may be empty. |
Figure 13-137 shows some typical operations. |
A string that is the name of the operation (not including parameters). |
A string containing a comma-separated list of names of classifiers(classes, data types, or interfaces). |
The type string follows a colon (:) that followsthe parameter list of the operation. |
Some, but not all, pro-gramming languages support multiple return values. |
The visibility is shown as one of the punctuation marks ‘+’, ‘#’, or ‘-’,representing public, protected, or private. |
Alternately, visibility can be shown as akeyword within the property string (for example, {visibility=private}). |
This formmust be used for user-defined or language-dependent choices. |
An operation and a method are declared using the same syntax. |
The top-most appearance of an operation signature within a generalization hierarchy is thedeclaration of an operation. |
Identical signatures in descendant classes are redun-dant declarations of the operation, but these may be useful for declaring methodsor for declaring operations when the classes are developed separately. |
If an opera-tion declaration has the abstract property (notated by operation name in italics orthe keyword abstract), then there is no method corresponding to the declaration. |
Otherwise, the declaration represents both an operation declaration and a methodimplementing it. |
In matching operations and methods, the name of the operation and the or-dered list of parameter types are used, not including return parameters. |
If the re-maining properties are inconsistent (for example, an in-parameter is matched toan out-parameter), then there is a conflict and the model is ill formed. |
If two identical operation declarations have no common ancestor operationdeclaration, yet are inherited by a common class, then the model is ill formed. |
The body of a method may be shown as a string within a note at-tached to an operation declaration. |
Otherwise, it should be normal text if it is just a natural-language de-scription of the behavior (a comment). |
The connection of a method declarationand its state machine or collaboration has no visual representation, but it wouldgenerally be represented by a hyperlink within an editing tool. |
An expression describing the effects of performing the operation. |
This may be stated in various ways, including text, before-after conditions, and in-variants. |
In any case, the specification should be expressed in terms of the observ-able effects of the operation on the state of the system, not in terms of theexecution algorithm. |
The algorithm is the business of the method. |
The choice true may also be shown by the keyword query. |
Theabsence of an explicit choice indicates the choice false—that is, the operation mayalter the system state (but it does not guarantee to alter it). |
Theabsence of an explicit choice indicates the choice true—that is, overridable. |
An instance-scope operation is indicated by not underlining the operationstring. |
A class-scope operation is indicated by underlining the name string. |
The choice is shown by a property string of the form concur-rency=value, where the value is one of sequential, guarded, or concurrent. |
To indicate that a class accepts a signal, the keyword «signal» is placed infront of an operation declaration within the list of operations. |
The declaration may not have a return type. |
The re-sponse of the object to the reception of the signal is shown with a state machine. |
Among other uses, this notation can show the response of objects of a class to er-ror conditions and exceptions, which should be modeled as signals. |
The argument list and return type may be suppressed (together, not separately). |
A tool may show the visibility indication in a different way, such as by using a spe-cial icon or by sorting the elements by group. |
The syntax of the operation signature string can be that of a particular program-ming language, such as C++ or Smalltalk. |
Operation names typically begin with a lowercase letter. |
Operation names are shown in plain face. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.