The Object Constraint Language is a declarative language for describing rules that apply to UML models developed at IBM and now part of the UML standard. Initially OCL was only a formal specification language extension to UML. OCL may now be used with any Meta-Object Facility OMG metamodel, including UML. The Object Constraint Language is a precise text language that provides constraint and object query expressions on any Meta-Object Facility model or metamodel that cannot otherwise be expressed by diagrammatic notation. OCL is a key component of the new OMG standard recommendation for transforming models, the QVT specification. Any QVT language like ATL is built on top of OCL and a rule execution engine.
Description
OCL is a descendent of
Syntropy, a second-generation object-oriented analysis and design method. The OCL 1.4 definition specified a constraint language. In OCL 2.0, the definition has been extended to include general object query language definitions.
OCL language statements are constructed in four parts:
- a context that defines the limited situation in which the statement is valid
- a property that represents some characteristics of the context (e.g., if the context is a class, a property might be an attribute)
- an operation (e.g., arithmetic, set-oriented) that manipulates or qualifies a property, and
- keywords (e.g., if, then, else, and, or, not, implies) that are used to specify conditional expressions.
OCL and UML
OCL supplements UML by providing expressions that have neither the ambiguities of natural language nor the inherent difficulty of using complex mathematics. OCL is also a navigation language for graph-based models.
OCL and MOF
OCL allows one to make any
Meta-Object Facility model more precise by associating to its metaelements a number of assertions.
OCL and QVT
Of particular importance to
Model Driven Engineering or
model-driven architecture is the notion of
Model transformation. The
OMG has defined a specific standard for model transformation called
MOF/QVT or in short
QVT. Several model transformation languages like
GReAT,
VIATRA or the
ATL are presently available, with different level of compliance with the QVT standard. Many of these languages are buit on top of OCL, which is the main part of the
QVT-compliance.
Alternatives
As a navigation language,
XPath may be considered as an altenative to OCL. However XPath works for XML trees while OCL allows to navigate
MOF-based models and metamodels. In other words OCL has a similar relation to
UML or MOF than
XPath has to
XML.
As a model specification language allowing to decorate a model or a metamodel with side-effect free annotations, OCL could be advantageously replaced by languages like
Alloy.
See also
External links
Unified Modeling Language | Specification languages | Formal methods | Software engineering | Data engineering | System engineering | Domain Specific Languages
Object Constraint Language | Lenguaje de especificación OCL2.0 | Object Constraint Language | OCL