OCL Expressions
mNo edit summary
No edit summary
 
(21 intermediate revisions by 5 users not shown)
Line 1: Line 1:
'''What is Object Constraint Language'''
'''Object Constraint Language''' ('''OCL''') is a [[wikipedia:Declarative_programming|declarative language]] for describing rules that apply to [[wikipedia:Unified_Modeling_Language|Unified Modeling Language (UML)]] models developed at [[wikipedia:IBM|IBM]] and now part of the UML standard. Initially, OCL was only a formal specification language extension to UML.<sup>[1]</sup> OCL may now be used with any [[wikipedia:Meta-Object_Facility|Meta-Object Facility]](MOF), [[wikipedia:Object_Management_Group|Object Management Group]](OMG), [[wikipedia:Metamodeling|meta-model]], including UML.<sup>[2]</sup> 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 ([[wikipedia:QVT|QVT]]) specification.


The '''Object Constraint Language (OCL)''' is a [[wikipedia:Declarative_programming|declarative language]] for describing rules that apply to [[UML School|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.[2] 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.
===== Different ways MDriven relies on OCL: =====
* As a constraint definition on a class
* As a description of derivation rule on derived attributes
* As a description of derivation of derived associations
* As ViewModel columns and Nesting definitions
* As definitions for Visible and Enable state for ViewModel columns
* As an expression of style information on ViewModel columns
* As an expression for object presentation on classes
* Action Enable expression
* State machine Guards
OCL expression must be without side effects. It is a query language and as such it is not expected to change data as the language is applied.


==== [[Part 1 OCL Common Expressions]] ====
====== Learn more: ======
 
==== [[Part 1 OCL Common Expressions|Part 1 OCL: Common Expressions]] ====


==== [[Part 2 OCL: Operators]] ====
==== [[Part 2 OCL: Operators]] ====


==== [[Part 3 OCL: Derivation properties]] ====
==== [[Part 3 OCL: Derivation properties|Part 3 OCL: Derivation Properties]] ====
I often get the question if OCL is capable of doing everything we need to do in a line of business application. The answer is that as long as the arguments and result is representable in your model – yes it will do anything. Sometimes you have external or ambient data not accessible from the model – then you cannot use OCL – until you make that data available.
The MDriven Book - See also: [[Training:Certain important constructs|Certain important constructs]]
 
[[Category:OCL]]
Not only can you do everything you need – it also comes out in small easily interpreted snippets of text that very much looks just like the requirements you are set to implement.
[[Category:Beginner]]
 
[[Category:The MDriven Book]]
I like to compare OCL and modeling with Calculus. In math you can discuss numbers and operators on those number in plain language – but you seldom do since it will be error prune and require you to use a lot of words for even simple things. Instead everyone actually doing math uses calculus notation to write up expressions. The expressions are often reduced to the smallest possible – so that they are easily understood and ready to be used for a purpose.
 
Use OCL for the same reason but not on only numbers but on all your designed information. Imagine a world without a good way to declaratively work with math. In this world we would probably not have been able to do much cool technology. The ability to convey compact math between people is very good for mankind. I am certain that a good compact way to convey rules on information is equally important – if not even more usable – for mankind.

Latest revision as of 05:28, 3 April 2024

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.[1] OCL may now be used with any Meta-Object Facility(MOF), Object Management Group(OMG), meta-model, including UML.[2] 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.
Different ways MDriven relies on OCL:
  • As a constraint definition on a class
  • As a description of derivation rule on derived attributes
  • As a description of derivation of derived associations
  • As ViewModel columns and Nesting definitions
  • As definitions for Visible and Enable state for ViewModel columns
  • As an expression of style information on ViewModel columns
  • As an expression for object presentation on classes
  • Action Enable expression
  • State machine Guards

OCL expression must be without side effects. It is a query language and as such it is not expected to change data as the language is applied.

Learn more:

Part 1 OCL: Common Expressions

Part 2 OCL: Operators

Part 3 OCL: Derivation Properties

The MDriven Book - See also: Certain important constructs

This page was edited 36 days ago on 04/03/2024. What links here