ITWissen.info - Tech know how online

object constraint language (OCL)

Object Constraint Language (OCL) is a declarative language for defining constraints on UML models so that expressions have no side effects. It involves adding specifying information to graphical UML models in textual notation.

The primary application of OCL is in the formulation of invariants in the sense of constraints on the validity of object models. An invariant is a constraint that should be true for an object during its entire lifetime. In addition, OCL is also used to specify Well-Formedness Rules (WFR) for UML models at meta-model level.

The development of the Object Constraint Language (OCL)

Object Constraint Language (OCL) was originally designed by IBM back in 1995 as a business engineering language. Later, OCL was standardized as a formal specification language within the UML (Unified Modeling Language) specification by the Object Management Group ( OMG). A corresponding specification can be viewed via the link below.

The OCL is not a programming language, and it does not provide any constructs for control flow control. By using OCL, requirements can be specified more concretely, and their implementation in source code implementations can be guaranteed without further interpretation and friction losses. Another possibility of using OCL arises in the context of Model Driven Architecture( MDA), especially in connection with model transformations and related languages such as QVT or ATLAS Transformation Language( ATL).

OCL for the description of properties

The Object Constraint Language (OCL) is used for the formal description of properties of object-oriented systems. OCL can be used to specify class and component invariants as well as pre- and post-conditions of operations(methods). Also query expressions and derivation rules for computable attributes are representable. Furthermore, constraints for groups of model elements are possible, for example, in connection with associations. OCL is oriented towards simple readability and manageability, even though OCL is also based on set theory and predicate logic.

To present OCL in all its power at this point would exceed the scope of this article by far - please refer to the OCL specification. Nevertheless, some important characteristics of OCL will be briefly summarized here:

Examples of OCL expressions

Examples of OCL expressions

  • An OCL expression is always defined within a specific context. If the assignment is not graphically obvious, it is explicitly indicated by the keyword context.
  • The type of expression is specified by the keyword following the context, distinguishing seven different types: invariants for classes and types in class diagrams, invariants for stereotypes, preconditions and postconditions for operations, guards for state transitions, constraints of operations, derivation rules of attributes, and targets of messages and actions.
  • The OCL knows simple comparison types similar to those in SQL.
  • There are collection types (collections) and related operations (seen in the example with select()). Very powerful iterator operations are supported, which are strongly oriented towards mathematical expressions.
  • An OCL can never change the state of objects during its evaluation - OCL is free of side effects.
  • OCL is a type-based (even type-safe) language, so all expressions must always be type-conformant.
  • Navigations over relations are possible with the dot operator (.).
  • OCL can handle inheritance and polymorphism.
Informations:
Englisch: object constraint language - OCL
Updated at: 01.11.2013
#Words: 505
Links: unified modelling language (Internet) (UML), information, notation, application (app), object (O)
Translations: DE
Sharing:    

All rights reserved DATACOM Buchverlag GmbH © 2024