OCL in EMFAshwani Kr Sharma, SAP Labs India
AgendaWhy OCL ?
What is OCL ?
When OCL ?
OCL in EMF ?Why OCL ? There are different categories of jobs,
 Each category requires different skills.
 Each plumber may have a different repertoire of skillsBusiness Rule:Each Job's assignee's skills include all the Job's category's requirements.….
UML SolutionsUML 1.x Use your favorite programming language
Ada/C/...
Magically inserted by proprietary code generator
UML 2.x Use a neutral specification language
The Object Constraint Language
State machine guards/actions
Class invariants
Operation bodies, pre/post conditions
Property initial/derived valuesWhy OCL ?Business Rule:Each Job's assignee's skills include all the Job's category's requirements.OCL-Job ::assignee.skills-->includes (category.requirements)
Why OCL ?In object-oriented modeling, a graphical model, like a class model, is not enough for a precise and unambiguous specification
The business rules are not captured.
Natural languages are ambiguous.
Formal languages is are useable to persons with a string mathematical background, but difficult for the average business or system modeler to useWhat is OCL ?Object Constraint Language (OCL), is a formal language to express side effect-free constraints. Users of the Unified Modeling Language and other languages can use OCL to specify constraints and other expressions attached to their models.
OCL is an add-on feature of UML, used to describe constraints, rules, specifications.What is OCL ?Natural/Formal Language compromise
natural language error prone
formal language unapproachable to many
Specification (not Programming) Language
declarative, modeling language
side effect free, no model changes, atomic execution
strongly typed, using UML generalizationOCL is typed !OCL is a typed language, so each OCL expression has a type. In a correct OCL expression all types used must be type conformant
OCL is a pure expression language OCL expression is guaranteed to be without side effect; it cannot change anything in the modelWhenever an OCL expression is evaluated, it simply delivers a value.
Mathematical operatorsInfix:          +, -, *, /                  and, or, xor, implies
                  =, <>, <, >, <=, >= , =, <>Prefix:       not, -4.0 * -5    'a' + 'b'Operators: mod, div, max, min, ...4.max(5)
OCL ExpressionsIfExpressionsif gender = Gender::MALE
    then 'he'
    else 'she'endifLet Expressionslet jack : Person = child('Jack'),
        jill : Person = child('Jill')
    in jack <> null and jill <> null

OCL in EMF

Editor's Notes

  • #3 Not associated with NWIts an 8.0 topic