Object Constraint Language
Encyclopedia
The Object Constraint Language (OCL) is a declarative language for describing rules that apply to Unified Modeling Language
(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
(MOF) Object Management Group
(OMG) meta-model, including UML. The Object Constraint Language is a precise text language that provides constraint and object query expressions on any MOF model or meta-model that cannot otherwise be expressed by diagrammatic notation. OCL is a key component of the new OMG standard recommendation for transforming models, the Queries/Views/Transformations (QVT
) specification.
, 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 statements are constructed in four parts:
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.
model more precise by associating assertions with its meta-elements.
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 Tefkat
are presently available, with different levels of compliance with the QVT standard. Many of these languages are built on top of OCL, which is the main part of the QVT
-compliance.
may be considered as an alternative to OCL. However Schematron works for Extensible Markup Language (XML) tree
s while OCL makes it possible to navigate MOF
-based models and meta-models (i.e. XML Metadata Interchange (XMI) trees). In other words, OCL has a similar relation to UML
or MOF as Schematron has to XML
. (Note that Schematron uses XPath
to navigate inside the XML trees.)
/>As a model specification language permitting designers to decorate a model or a meta-model with side-effect-free annotations, OCL could be replaced by languages like Alloy
.
Unified Modeling Language
Unified Modeling Language is a standardized general-purpose modeling language in the field of object-oriented software engineering. The standard is managed, and was created, by the Object Management Group...
(UML) models developed at IBM
IBM
International Business Machines Corporation or IBM is an American multinational technology and consulting corporation headquartered in Armonk, New York, United States. IBM manufactures and sells computer hardware and software, and it offers infrastructure, hosting and consulting services in areas...
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
Meta-Object Facility
The Meta-Object Facility is an Object Management Group standard for model-driven engineering. The official reference page may be found at OMG's website.- Overview :...
(MOF) Object Management Group
Object Management Group
Object Management Group is a consortium, originally aimed at setting standards for distributed object-oriented systems, and is now focused on modeling and model-based standards.- Overview :...
(OMG) meta-model, including UML. The Object Constraint Language is a precise text language that provides constraint and object query expressions on any MOF model or meta-model that cannot otherwise be expressed by diagrammatic notation. OCL is a key component of the new OMG standard recommendation for transforming models, the Queries/Views/Transformations (QVT
QVT
QVT is a standard set of languages for model transformation defined by the Object Management Group .- Overview :...
) specification.
Description
OCL is a descendant of SyntropySyntropy
Syntropy is a second-generation object-oriented analysis and software design method developed at Object Designers Limited in the UK during the early 1990s. The goal in developing Syntropy was to provide a set of modelling techniques that would allow precise specification and would keep separate...
, 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 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 UMLUnified Modeling Language
Unified Modeling Language is a standardized general-purpose modeling language in the field of object-oriented software engineering. The standard is managed, and was created, by the Object Management Group...
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 makes a Meta-Object FacilityMeta-Object Facility
The Meta-Object Facility is an Object Management Group standard for model-driven engineering. The official reference page may be found at OMG's website.- Overview :...
model more precise by associating assertions with its meta-elements.
OCL and QVT
Of particular importance to Model Driven Engineering (MDE) or model-driven architectureModel-driven architecture
Model-driven architecture is a software design approach for the development of software systems. It provides a set of guidelines for the structuring of specifications, which are expressed as models. Model-driven architecture is a kind of domain engineering, and supports model-driven engineering of...
is the notion of Model transformation
Model transformation
A model transformation, in model-driven engineering, is an automatable way of ensuring that a family of models is consistent, in a precise sense which the software engineer can define...
. The OMG
Object Management Group
Object Management Group is a consortium, originally aimed at setting standards for distributed object-oriented systems, and is now focused on modeling and model-based standards.- Overview :...
has defined a specific standard for model transformation called MOF/QVT or in short QVT
QVT
QVT is a standard set of languages for model transformation defined by the Object Management Group .- Overview :...
. Several model transformation languages like GReAT
GReAT
Graph Rewriting and Transformation is a Model Transformation Language for Model Integrated Computing available in the GME environment. GReAT has a rich pattern specification sublanguage, a graph transformation sublanguage and a high level control-flow sublanguage. It has been designed to address...
, VIATRA
VIATRA
The VIATRA framework is the core of a transformation-based verification and validation environment for improving the quality of systems designed using the Unified Modeling Language by automatically checking consistency, completeness, and dependability requirements.- Target Application Domains...
, or Tefkat
Tefkat
Tefkat is a Model Transformation Language and a model transformation engine. The language is based on F-logic and the theory of stratified logic programs. The engine is an Eclipse plug-in for the Eclipse Modeling Framework .- History :...
are presently available, with different levels of compliance with the QVT standard. Many of these languages are built on top of OCL, which is the main part of the QVT
QVT
QVT is a standard set of languages for model transformation defined by the Object Management Group .- Overview :...
-compliance.
Alternatives
As a rule-based validation language, SchematronSchematron
In markup languages, Schematron is a rule-based validation language for making assertions about the presence or absence of patterns in XML trees...
may be considered as an alternative to OCL. However Schematron works for Extensible Markup Language (XML) tree
XML tree
XML documents have a hierarchical structure and can conceptually be interpreted as a tree structure, called an XML tree.This tree structure can not be divided into just root, nodes and leaves as normal tree structures...
s while OCL makes it possible to navigate MOF
Meta-Object Facility
The Meta-Object Facility is an Object Management Group standard for model-driven engineering. The official reference page may be found at OMG's website.- Overview :...
-based models and meta-models (i.e. XML Metadata Interchange (XMI) trees). In other words, OCL has a similar relation to UML
Unified Modeling Language
Unified Modeling Language is a standardized general-purpose modeling language in the field of object-oriented software engineering. The standard is managed, and was created, by the Object Management Group...
or MOF as Schematron has to XML
XML
Extensible Markup Language is a set of rules for encoding documents in machine-readable form. It is defined in the XML 1.0 Specification produced by the W3C, and several other related specifications, all gratis open standards....
. (Note that Schematron uses XPath
XPath
XPath is a language for selecting nodes from an XML document. In addition, XPath may be used to compute values from the content of an XML document...
to navigate inside the XML trees.)
/>As a model specification language permitting designers to decorate a model or a meta-model with side-effect-free annotations, OCL could be replaced by languages like Alloy
Alloy language
In computer science and software engineering, the Alloy Analyzer is a software tool which can be used to analyze specifications written in the Alloy specification language. The Analyzer can generate instances of model invariants, simulate the execution of operations defined as part of the model,...
.
See also
- Computer model
- Data mappingData mappingData mapping is the process of creating data element mappings between two distinct data models. Data mapping is used as a first step for a wide variety of data integration tasks including:...
- Domain Specific Language (DSL)
- Domain-specific modelling (DSM)
- EclipseEclipse (software)Eclipse is a multi-language software development environment comprising an integrated development environment and an extensible plug-in system...
GMT Project - Gello Expression LanguageGello Expression LanguageThe GELLO Expression Language was started in 2001 and introduced in 2002; in 2005, GELLO was adopted as an international standard by HL7 International and ANSI for a decision support language...
- Glossary of Unified Modeling Language termsGlossary of Unified Modeling Language termsThis glossary of Unified Modeling Language terms covers all versions of UML. Individual entries will point out any distinctions that exist between versions.-A:...
- Intentional ProgrammingIntentional ProgrammingIn computer programming, intentional programming is a collection of concepts which enable software source code to reflect the precise information, called intention, which programmers had in mind when conceiving their work...
(IP) - List of UML tools
- Meta-model
- Meta-modeling
- Meta-modeling technique
- Meta-Object FacilityMeta-Object FacilityThe Meta-Object Facility is an Object Management Group standard for model-driven engineering. The official reference page may be found at OMG's website.- Overview :...
(MOF) - MetadataMetadataThe term metadata is an ambiguous term which is used for two fundamentally different concepts . Although the expression "data about data" is often used, it does not apply to both in the same way. Structural metadata, the design and specification of data structures, cannot be about data, because at...
- Model-based testingModel-based testingModel-based testing is the application of Model based design for designing and optionally executing the necessary artifacts to perform software testing. Models can be used to represent the desired behavior of the System Under Test , or to represent the desired testing strategies and testing...
(MBT) - Model-driven architectureModel-driven architectureModel-driven architecture is a software design approach for the development of software systems. It provides a set of guidelines for the structuring of specifications, which are expressed as models. Model-driven architecture is a kind of domain engineering, and supports model-driven engineering of...
(MDA) - Model Driven Engineering (MDE)
- Model Transformation LanguageModel Transformation LanguageA model transformation language in systems and software engineering is a language for model transformation.- Overview :The notion of model transformation is of central importance to information technology. A software system may be seen as a set of information transformations...
(MTL) - Modeling languageModeling languageA modeling language is any artificial language that can be used to express information or knowledge or systems in a structure that is defined by a consistent set of rules...
- Modeling perspectivesModeling perspectivesA modeling perspective in information systems is a particular way to represent pre-selected aspects of a system. Any perspective has a different focus, conceptualization, dedication and visualization of what the model is representing....
- MOFM2T
- Object-oriented analysis and designObject-oriented analysis and designObject-oriented analysis and design is a software engineering approach that models a system as a group of interacting objects. Each object represents some entity of interest in the system being modeled, and is characterised by its class, its state , and its behavior...
(OOAD) - MOF Queries/Views/TransformationsQVTQVT is a standard set of languages for model transformation defined by the Object Management Group .- Overview :...
(QVT) - Semantic translationSemantic translationSemantic translation is the process of using semantic information to aid in the translation of data in one representation or data model to another representation or data model...
- Transformation languageTransformation languageA transformation language is a computer language designed to transform some input text in a certain formal language into a modified output text that meets some specific goal....
(TL) - UML toolUML toolA UML tool or UML modeling tool is a software application that supports some or all of the notation and semantics associated with the Unified Modeling Language , which is the industry standard general purpose modeling language for software engineering.UML tool is used broadly here to include...
- Vocabulary-based transformationVocabulary-based transformationIn metadata, a vocabulary-based transformation is a transformation aided by the use of a semantic equivalence statements within a controlled vocabulary.Many organizations today require communication between one or more computers...
- XMI
- XML transformation languageXML transformation languageAn XML transformation language is a programming language designed specifically to transform an input XML document into an output XML document which satisfies some specific goal.There are two special cases of transformation:...
(XTL)
External links
- OMG OCL specification page
- OCL Portal - The center for OCL related information
- OCL page of Computer Science Dept. of CSUSB (brief OCL 2.0 syntax)
- Octopus: OCL Tool for Precise Uml Specifications (OCL checker)
- Dresden OCL Toolkit (OCL Toolkit, various OCL related publications)
- HOL-OCL (An interactive theorem proof environment for OCL, various OCL related publications)
- OCL for Java tutorial on ParlezUML
- Article on using EMF's OCL in Java code
- UML link page on cetus-links.org
- USE (UML-based Specification Environment) (OCL Tool for model validation, various OCL related publications)