Visual OCL

TU-Berlin | Faculty IV | Institute ISTI | Research group TFS

Language elements with examples

small logo
section: < previous | next >
| |
chapter: << previous | next >>

3.2 The Boolean expression "and"

Two expressions put next to each other define implicitly an "and" expression. Intuitively all expressions have to be fulfilled, if there is more than one on the same level, so VOCL just uses this intuition for an easy version of the "and" expression.

The example in figure 3.3 describes as before in figure 3.2, that the spouse of a person has to be at least 18 years old, but this time the navigation to the attribute has only to be done, if there is a spouse of the considered person.

The corresponding OCL text is:
context
Person inv:
self.wife->notEmpty() implies self.wife.age >= 18
and self.husband->notEmpty() implies self.husband.age >= 18
Fig. 3.3 A constraint with an "and" expression

3.2 The Boolean expression "not"

The negation of a VOCL expression holds in context of an invariant, if there is no configuration which fulfils this inner expression. Graphically there is a box around the expression, which has to be negated and on top of the box is placed the label "not".

The example in figure 3.4 describes, that a manager of a company is not allowed to be married.

The corresponding OCL text is:
context
Company inv: not (self.manager.isMarried)
Fig. 3.4 A constraint with a "not" expression

  section: < previous | next >
| |
chapter: << previous | next >>
©2005 TFS