Chapter 12. Advanced Features

Table of Contents
Constraints with OCL
Critiques
Searching for Model Elements

Constraints with OCL

UML is basically a graphical language. As a graphical language it is very suitable for expressing high-level abstractions for architectures, workflows, processes etc. But for expressing very detailed and fine-grained things like algorithms, equations or constraints, textual languages just tend to be more convenient.

The current UML recognizes this and comes with a supplementary textual language to express constraints. This language is called the Object Constraint Language, or abbreviated OCL.

Since OCL is noted as text, it is simple to support, and many UML tools do it just that way. You can simply enter lines of text in certain fields reserved for constraints. In Poseidon for UML you can do that in the Constraints tab on the Details pane, as shown in the figure below.

Figure 12-1. A Constraints tab.

But also because it is text, it is quite difficult to tell - just by looking at it - whether syntax and semantics are used correctly. Poseidon does help you there extensively, and to our knowledge is best at doing this. The Constraints tab on the Details pane holds an OCL editor that comes with its own syntax assistance mode, which you have to enable first.

Figure 12-2. Edit constraints.