Do you wonder how to add expressions and constraints to your UML and OO models? Well, Object Constraint Language is the answer!
The Object Constraint Language (OCL) is a language that enables you to describe expressions and constraints on object-oriented models and not only. An expression is an indication or specification of a value. A constraint is a restriction on one or more values of an object-oriented model or system.
For example, expressions usage in your UML model might be for:
On the other hand constraints are distinguished in four types:
An example
The above Class diagram can be encanced with some OCL expressions. For example:
which contraints all the objects of Circle on their radius attribute to be always a positive value.
Another example is the following:
A constraint of the Polygon class where two vertex points of a polygon must be in different positions. It means that for all instances of polygons if any two vertex points have same coordinates it is actually the same instance.
The power of OCL
The real power of OCL usage to your applications, comes when you use it with a CASE tool, while you design your UML diagrams. When the model is not read by humans, but instead is used as input to an automated system, the use of OCL becomes even more important. Tools can be used for generating simulations and tests, for checking consistency, for generating derived models in other languages using MDA transformations, for generating code, and so on. This is something we did in CORFU.
Probe further:
The authors of the famous book The Object Constraint Language: Precise Modelling with UML. http://www.klasse.nl/ocl/
Check http://www.omg.org for the latest specification of OCL
See how to use it with Eclipse
and of course wikipedia
Recent comments
13 years 31 weeks ago
13 years 32 weeks ago
13 years 33 weeks ago
13 years 35 weeks ago
13 years 35 weeks ago
13 years 36 weeks ago
13 years 36 weeks ago
13 years 36 weeks ago
13 years 37 weeks ago
13 years 38 weeks ago