ArticleslgStudy

science

Object Constraint Language

Object Constraint Language is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Object Constraint Language rather than just read about it. In short: The Object Constraint Language (OCL) is a declarative language describing rules applying to Unified Modeling Language (UML) models developed at IBM and is now part of the UML standard. Initially, OCL was merely a formal specification language extension for UML.

Key takeaways

  • Object Constraint Language belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Object Constraint Language to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Object Constraint Language from memory before moving on to harder problems.

Reference excerpt

The Object Constraint Language (OCL) is a declarative language describing rules applying to Unified Modeling Language (UML) models developed at IBM and is now part of the UML standard. Initially, OCL was merely a formal specification language extension for 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.

Description OCL is a descendant 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 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.

Relation

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 makes a Meta-Object Facility model more precise by associating assertions with its meta-elements.

OCL and QVT Of particular importance to Model Driven Engineering (MDE) 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 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.

Alternatives Being a rule-based validation language, Schematron may be considered an alternative to OCL. However Schematron works for Extensible Markup Language (XML) trees while OCL makes it possible to navigate MOF-based models and meta-models (i.e. XML Metadata Interchange (XMI) trees). In other words, OCL relates to UML or MOF similarly to how Schematron relates to XML. (Note that Schematron uses XPath to navigate inside the XML trees.)Being 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. Automated OCL generation is in principle possible from natural language.

Examples

Extensions Eclipse OCL extends Standard OCL with additional operators and a type for Maps. AgileUML extends Standard OCL with Map and Function types. These extensions are consistent with the map and function types present in modern programming languages such as Python and Swift.

See also Computer model Data mapping Domain Specific Language (DSL) Domain-specific modelling (DSM) Eclipse GMT Project Gello Expression Language Glossary of Unified Modeling Language terms List of UML tools Meta-modeling Meta-modeling technique Meta-Object Facility (MOF) Metadata Model-based testing (MBT) Model-driven architecture (MDA) Model Driven Engineering (MDE) Model Transformation Language (MTL) Modeling language Modeling perspectives MOFM2T Object-oriented analysis and design (OOAD) MOF Queries/Views/Transformations (QVT) Semantic translation Transformation language (TL) UML tool Vocabulary-based transformation XMI XML transformation language (XTL)

References

External links OMG OCL specification 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) OCL tutorial NL2OCL (OCL Tool for invariant generation from NL)

Worked examples

Example 1 — a first encounter with Object Constraint Language

Start with the simplest possible case. Write down what Object Constraint Language claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Object Constraint Language before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Object Constraint Language ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Object Constraint Language

In research
Object Constraint Language appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Object Constraint Language in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Object Constraint Language is common in secondary-school and first-year university syllabi. It links to neighbouring topics Formal specification languages, ISO standards, Unified Modeling Language, so understanding it makes those chapters shorter.
In everyday life
Look for Object Constraint Language outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Object Constraint Language in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Object Constraint Language means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Object Constraint Language out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Object Constraint Language in simple terms?

The Object Constraint Language (OCL) is a declarative language describing rules applying to Unified Modeling Language (UML) models developed at IBM and is now part of the UML standard. Initially, OCL was merely a formal specification language extension for UML.

Why does Object Constraint Language matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Object Constraint Language?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Object Constraint Language.

Tags

  • Formal specification languages
  • ISO standards
  • Unified Modeling Language

Keep exploring