section: < previous | next > |
| | |
chapter: << previous | next >> |
1. Basic Elements of VOCL
We describe the elements of VOCL with means of examples for the corresponding OCL-expressions. The main components are navigation expression, Boolean expression, Let expressions and complex expressions.
The visual representation of VOCL elements orientates on collaboration diagrams in UML.
1.1 Constraint
A VOCL-constraint is the container of a VOCL-expression and is shown in the following figure. At the top of a rounded rectangle stands the context of the constraint, which can be an invariant for a class or either a pre or post condition for a method. The body of the rectangle contains the VOCL-expression, describing the structural condition. On the bottom is place for conditions on variables, used in the body. |
|
Fig. 1.1 A constraint in VOCL |
|
|
1.2 Classifier Roles
Simple constraints describe conditions for Attributes and return values of Methods belonging to an instance of a class from an UML class diagram. The representation of an instance accords with collaboration diagrams in UML. Therefore the classifier role is underlined and has an identifier with a colon followed by the class name. Attributes can be added underneath.
|
|
Fig. 1.2 VOCL Constraint with a classifier role |
|
The example shown in figure 1.2 describes a condition for the class Company. The restriction means, that each company has to have at least 50 employees. Every Constraint has the pre defined variable self, which relates to an object of the class from the context and is the start of the navigation through the constraint. This variable can be renamed in the context.
The corresponding OCL text is:
context Company inv:
self.numberOfEmployees > 50 |
|
|
section: < previous | next > |
| | |
chapter: << previous | next >> |