SlideShare uma empresa Scribd logo
1 de 61
Baixar para ler offline
Enriching Your Models
with OCL
Adolfo Sánchez-Barbudo Herrera, Open Canarias
Axel Uhl, SAP
Edward Willink, MDT/OCL Project Lead

3rd November 2010

Made available under EPL v1.0
Overview
MDT/OCL team
● Why and When OCL
● Introduction to OCL
● OCL within Eclipse
● OCL Use Cases, coming soon
SAP
●
Scaling up OCL at SAP

Enriching your models with OCL

Made available under EPL v1.0

2
Follow Along
http://www.eclipsecon.org/summiteurope2010/sessions/?page=sessions&id=1710

links to slides and to zip file comprising, model,edit,editor,diagram projects

MDT/OCL 3.0.1 Examples and Editors

●

Install

●

Import ... Existing Projects from Archive
–

●

ESEExampleTree/model/People1.ecore

Run nested Eclipse, Import ESEExampleTree
–

ESEExampleTree/model/default.people_diagram

Enriching your models with OCL

Made available under EPL v1.0

3
How Much OCL?
None
●

Very simple modeling

●

Java augmented modeling

A little
●

OCL (and Java) augmented modeling

A lot
●

OCL as a powerful formal specification language
–

●

OCL as the foundation of a transformation language
–

●

OMG's UML, OCL, QVT, ... specifications
MOFM2T (Acceleo), QVT

OCL as a portable implementation language
Enriching your models with OCL

Made available under EPL v1.0

4
UML State Machines

●

Need to specify behavior
●

amber when End of Stop or Start of Stop

●

transition when signal received/time elapsed
Enriching your models with OCL

Made available under EPL v1.0

5
UML Solutions
UML 1.x Use your favourite 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 values

Enriching your models with OCL

Made available under EPL v1.0

6
Simple Meta-Modeling
Graphics
●

Box
–

●

Compartment
–

●

Enriching your models with OCL

Association

Decoration
–

Example Family Tree Meta-Model
Ecore Diagram
(similar to UML Class Diagram)

Property, operation

Line
–

●

Class, enumeration

Composition, navigability

Text
●

Name, type, stereotype

●

Multiplicity

Made available under EPL v1.0

7
Richer Meta-Modelling
●

Implicit constraints
●
●

●

Up to 2 parents
MALE/FEMALE gender

Arbitrary constraints
●
●

1 MALE, 1 FEMALE parent

●

Enriching your models with OCL

At least 5 characters in name
Self is not an ancestor of self

Made available under EPL v1.0

8
Example Family Tree Model

Simple GMF Diagram Editor
ESEExampleTree/model/default.people_diagram
Enriching your models with OCL

Made available under EPL v1.0

9
Simple Query Evaluation

Window->Show View->Other... Console
Console: New: Interactive OCL
Select Zeus as the Model Context (in any model editor)
Type children then carriage return
Enriching your models with OCL

Made available under EPL v1.0

10
OCL Principles
●

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 generalization

Enriching your models with OCL

Made available under EPL v1.0

11
OCL Object Types
●

Primitive Types
–
–

Boolean, String
Real, Integer, UnlimitedNatural
●

●

unlimited; no float/double etc distinction

Bottom Types
–
–

●

OclVoid: any value can be null
OclInvalid: any value can be invalid

Top Type
–

OclAny: every OCL and user type
conform to OclAny type.

Enriching your models with OCL

Made available under EPL v1.0

12
Mathematical Operators
Infix:

+, -, *, /
and, or, xor, implies
=, <>, <, >, <=, >=
Prefix:
not, 4.0 * -5
'a' + 'b'
Operators: mod, div, max, min, ...
4.max(5)

Enriching your models with OCL

Made available under EPL v1.0

nb =, <>

13
OCL Expressions
●

If Expressions
if gender = Gender::MALE
then 'he'
else 'she'
endif

●

Let Expressions
let jack : Person = child('Jack'),
jill : Person = child('Jill')
in jack <> null and jill <> null
Enriching your models with OCL

Made available under EPL v1.0

14
More Complex Query

Selecting Poseidon defines the implicit context variable
self : Person = Poseidon
Enriching your models with OCL

Made available under EPL v1.0

15
Object Navigation

Properties
●

self.name or just name
(cf. this.getName() or getName())

Operations
●

self.child('John') or just child('John')
(cf. this.child('John') or child('John'))
Enriching your models with OCL

Made available under EPL v1.0

16
The OCLinEcore Editor

Select model/People1.ecore
Open With... OCLinEcore
Enriching your models with OCL

Made available under EPL v1.0

17
Example Validation Failure

Open model/People1.xmi with Sample Reflective Ecore Editor
Select Universe, Right button menu, Validate
Enriching your models with OCL

Made available under EPL v1.0

18
Multiplicities and Collections
Meta-models specify multiplicities
–
–
●

children : Person[*] {ordered,unique}
parents : Person[0..2] {unique}

multiplicities are specification concepts; not objects

Implementations (e.g. Ecore) reify multiplicities
–
●

getChildren() returns a UniqueEList<Person>

'many' properties have extra implementation objects
–
–

getName()
getChildren().get(2)

setName(newName)
getChildren().add(newChild)

OCL needs more than just UML multiplicities
Enriching your models with OCL

Made available under EPL v1.0

19
OCL 2.0 Collections
Typed Collections partially reify multiplicities
Collection(T)
Non-Unique
Unique

Unordered
Bag(T)
Set(T)

Ordered
Sequence(T)
OrderedSet(T)

Collections are different to objects
Navigation from a Collection uses ->
–

[Navigation from an Object (OclAny) uses .]

Collections have type parameters
Collections have useful operations
Collections have very useful iterations
Enriching your models with OCL

Made available under EPL v1.0

20
Example Collection Operations
Collection::size()
self.children->size()
'get'
Sequence::at(Integer) self.children->at(1)
– nb 1 is the first index, size() is the last
'add'
Collection(T)::including(T) : Collection(T)
– returns a new collection with added content
'contains'
Collection(T)::includes(T) : Boolean
– tests existing content
Enriching your models with OCL

Made available under EPL v1.0

21
Collection::select iteration
●

Children

self.children
●

Sons

self.children->select(gender = Gender::MALE)
self.children->select(child | child.gender = Gender::MALE)
self.children->select(child : Person | child.gender = Gender::MALE)

●

select(iterator : type | body)
–

●

reject(iterator : type | body)
–

●

filters to select elements for which the body is true
filters to reject elements for which the body is true

cf multi-line Java loop
Enriching your models with OCL

Made available under EPL v1.0

22
Collection::collect iteration
●

Children

self.children
●

Grandchildren

self.children->collect(children)
self.children->collect(child | child.children)
self.children->collect(child : Person | child.children)

●

collect(iterator : type | body)
–

●

creates a new collection comprising all the bodies

any, exists, forAll, isUnique, iterate, one,

Enriching your models with OCL

Made available under EPL v1.0

23
OCL Navigation Operators
anObject. ...
aCollection-> ...

object navigation
collection navigation

Object
Navigation
?

.
->

Collection
?
Navigation

Shorthands
aCollection. ...
anObject-> ...

Enriching your models with OCL

implicit collect
implicit collection

Made available under EPL v1.0

24
Implicit Collect Query

parents.parents = parents->collect(parents)
3 symbols, compared to 4 lines of Java
4 grandparents, but not all different!
Enriching your models with OCL

Made available under EPL v1.0

25
Cleaned up query

parents.parents->asSet()->sortedBy(name)
->asSet() converts to Set(Person), removes duplicates
->sortedBy(name) alphabeticizes

Enriching your models with OCL

Made available under EPL v1.0

26
Implicit Collection Conversion
.
->

Object
Navigation
Implicit Collection

Collection
Implicit collect()
Navigation

self->notEmpty()
●

Standard OCL idiom
–
–

Converts self (if an object) to a Collection of self
If self is a defined object
●

–

If self is an undefined object (null)
●

–

Implicit collection is not empty - true
Implicit collection is empty - false

If self is an error (invalid)
●

Implicit collection is also an error - invalid

Enriching your models with OCL

Made available under EPL v1.0

27
Collection::closure iteration

●

children, grandchildren, greatgrandchildren etc

self->closure(children)

Implicit collection of self, then closure of all children
[ closure in MDT/OCL 1.2, probably in OMG OCL 2.3 ]
●

Enriching your models with OCL

Made available under EPL v1.0

28
OCL as Implementation

any(x) iteration selects an arbitrary element for which x is true.
Enriching your models with OCL

Made available under EPL v1.0

29
Derived Properties

For Hera
invariant MixedGenderParents:
father.gender <>
mother.gender;

fails because
father is null and
mother is null
Enriching your models with OCL

Made available under EPL v1.0

30
Other OCL Capabilities
No time to mention
● Other iterators, operations
● Tuples
● Association Classes/Qualifiers
● @pre values
● Messages
● States

Enriching your models with OCL

Made available under EPL v1.0

31
OMG OCL Progress
OCL 2.2 (current) Collections are objects!
–
–
–

Collection conforms to OclAny
No need for Collection/Object polymorphic operations
Collections can mix Object/Collection content

? OCL 2.4 Specification defined by models
–
–
–

Auto-generated by Acceleo
Fix too many consistency/typo/realizability issues
Aligned with UML 2.4, MOF 2.4, XMI 2.4

Eclipse committers active on OMG RTF
Enriching your models with OCL

Made available under EPL v1.0

32
Eclipse MDT/OCL
●

OMG OCL 1.x
EMFT/OCL 1.0

Original code contribution by IBM

●

Java callable API
–

Parse/evaluate OCL 1.x against Ecore
meta-models

OMG OCL 2.2
MDT/OCL 3.0

Ecore or UML meta-models

●

OCL 2.0 (in so far as possible)

●

OMG OCL 2.0
MDT/OCL 1.2

●

Example Interactive Console

●

towards OCL 2.2

●

Example Xtext editors (Ecore only)

Enriching your models with OCL

Made available under EPL v1.0

33
Validation History
Eclipse 3.2

Use of OCL to define model validation
● EMF Validation Framework
–

●

Eclipse 3.3

EMF, OCL EAnnotations
–
–

Eclipse 3.6
EMF 2.6
MDT/OCL 3.0

●

Embed OCL in XML CDATA

Embed OCL in EAnnotation
Genmodel to integrate

Delegates
–
–
–

Embed OCL in EAnnotation
EObject.eInvoke() for dynamic invocation
OCLinEcore editor for semi-validated editing

Enriching your models with OCL

Made available under EPL v1.0

34
OCLinEcore Editor

●

Open with -> OCLinEcore

●

Save As *.ecore
–

●

Save As *.oclinecore
–

●

Loses formatting and comments
Text file preserves comments

Useful for plain Ecore too:
–
–

Printable/reviewable text
Searchable/replaceable text
Enriching your models with OCL

Made available under EPL v1.0

35
Validation in Sample Ecore Editor

OCLinEcore editor maintains EAnnotations automatically
OCLinEcore editor provides OCL syntax checking
OCLinEcore editor will provide OCL semantic checking
Enriching your models with OCL

Made available under EPL v1.0

36
(Example) Tools and Tips
OCLinEcore editor for Ecore/embedded OCL
CompleteOCL editor for OCL documents
EssentialOCL editor for OCL Expressions (Papyrus)
OCL Interactive Console
–
–

Invaluable ability to practice non-trivial expressions
Page Up/Page Down to reuse expressions

Meta-model reload after change
Genmodel settings for embedded OCL
Enriching your models with OCL

Made available under EPL v1.0

37
EMF Dynamic Instances

Create/update Ecore meta-model
Create XMI instance of EClass in meta-model
Update XMI model, validate OCL constraints
Enriching your models with OCL

Made available under EPL v1.0

38
Meta-model Update
UML
meta-model

realizes

My.uml

Ecore
meta-model

conformsTo

My.ecore

Model
data.my

Edit UML/Ecore meta-model in UML/Ecore editor
–
–

manual export of UML to Ecore in workspace
manual save of Ecore to workspace

Create Dynamic Instance/Load Model in editor
–

validate/evaluate OCL constraints

EMF does not support meta-model mutation
–
–

Model.eClass() reverts to an unresolved proxy
must exit and re-enter model editor

Enriching your models with OCL

Made available under EPL v1.0

39
Genmodel settings for OCL

If not set to true
●

MDT/OCL 3.0.0 OCL operation bodies not invoked

●

MDT/OCL 3.0.1 Error Log as dynamic fallback used
Enriching your models with OCL

Made available under EPL v1.0

40
Eclipse MDT/OCL Futures
3.1 Core (Indigo)
–

Minor maintenance

3.1 Examples (Indigo)
–
–
–
–

New Ecore/UML blind pivot meta-model
Extensible modelled Standard Library
Xtext editors
Super-compliant - anticipating OMG OCL resolutions

4.0 Core + Tools + Examples (Indigo+1)
–

3.1 Examples promoted to Core or Tools
●

–

preserved external APIs, significant revision of internal APIs

OCL to Java code generation

Enriching your models with OCL

Made available under EPL v1.0

41
Which OCL Use Cases work When
Validate

Evaluate

Console

Editor

Static Java
For Ecore

1.0

1.0

1.0
Examples

3.0
Examples

Static Java
For UML

1.2

1.2

3.1
Examples

3.1
Examples

Complete OCL
For Ecore

3.1
Examples

3.1
Examples

3.1
Examples

3.0
Examples

Complete OCL
For UML

3.1
Examples

3.1
Examples

3.1
Examples

3.1
Examples

Embedded
OCL in Ecore

3.0

3.0

3.0
Examples

3.0
Examples

Embedded
OCL in UML

3.1
Examples

3.1
Examples

3.1
Examples

3.1
Examples

Released in Helios Example functionality in Helios
Example functionality in Indigo, release in Indigo+1
Enriching your models with OCL

Made available under EPL v1.0

42
OCL 'Standard' Library
Problems: OMG
–
–
–

library is not a model
uses non-UML concepts (Iterator)
no reflection for OclAny::oclType()

Problems: MDT/OCL
–
–
–

hard coded, difficult to extend
UML/Ecore differences, long generic template lists
Ecore/EMOF discrepancies : EClass/Class

Solution: OMG
–

library is a model defined by the new OCL meta-model

Benefit: MDT/OCL
–

variants, extensible, unified, compliant

Enriching your models with OCL

Made available under EPL v1.0

43
OCL Models
Problems: OMG
–
–
–
–

OCL is not fully UML-aligned
OCL modifies UML models (OclAny)
Complete OCL modifies UML models
OCL requires a modified sub-UML @ run-time

Problems: MDT/OCL
–
–

UML/Ecore implementation differences, Ecore extension
Ecore/EMOF discrepancies

Solution: OMG
–
–

Pivot meta-model defines UML @ run-time
Pivot model realises OCL-defined merges

Benefit: MDT/OCL
–

unified, compliant, Ecore/EMOF hidden

Enriching your models with OCL

Made available under EPL v1.0

44
Evaluation
Problems: MDT/OCL:
–
–
–
–

OCL interpreted by Java
OperationCallExp visit is very inefficient
Slightly hard to extend for QVTo, Acceleo
OCL within genmodelled Java is just a String
●

significant first time parsing costs

Solution: MDT/OCL
–
–
–

OCL to Java code generation
Library model references a Java class per feature
Code efficiency

Benefit: MDT/OCL
–
–

extensible, faster (10 to 100 times ... iteration strategies)
Java in genmodelled Java

Enriching your models with OCL

Made available under EPL v1.0

45
Beyond OCL
OMG OCL is a powerful expression language
●

Declarative, First Order Predicate Calculus/Logic

●

Model-oriented, UML navigation, multiplicities, ...

Formal language supports formal analysis
analysis supports optimisation
OCL's usefulness calls for scalable
implementation

Enriching your models with OCL

Made available under EPL v1.0

46
The Re-Evaluation Problem
•

A set of OCL expressions

•

A set of model elements

•

A model change notification

•

•

Which of the OCL expressions may have
changed its value on which context elements?
Naïve approach
●

re-evaluate all expressions for all their contexts

●

takes O(|expressions| * |modelElements|)
Enriching your models with OCL

Made available under EPL v1.0

47
Example

self.signature.parameters->size() = self.arguments->size()

Enriching your models with OCL

Made available under EPL v1.0

48
Naïve Re-Evaluation Sequence
:Tool

reevaluator:Adapter

e : EObject

a
w
t's
ha
T

oo
t
y

!
w
lo
s
|expressions| times

1: change

2: notifyChanged(msg)

3: reevaluateAllExpressionsOnAllTheirContexts

|contexts| times

Enriching your models with OCL

Made available under EPL v1.0

49
Idea: Find out from Notification which
OCLExpressions may have changed
Example: OCLExpression
self.arguments->size() = self.signature.parameters->size()

generates Notification filter
(containment AND ((new value filter incl subs for: Call) OR
(old value filter incl subs for: Call))) OR
((wantedClass conformsTo: Signature) AND (feature: parameters)) OR
((wantedClass conformsTo: Call) AND (feature: signature)) OR
((wantedClass conformsTo: Call) AND (feature: arguments))

Many expressions cause
–

many adapters
with one (often non-trivial) Notification filter each

–

which need evaluation for each change Notification

–

Enriching your models with OCL

Made available under EPL v1.0

50
Filter Events for OCLExpressions
:Tool

one-time setup

{

reevaluator:Adapter

:ImpactAnalyzer

:EventManager

adapterForEventManager
: EventAdapter

e : EObject

1: createFilterForExpression(e)
2: returns eventFilter
3: subscribe(eventFilter, reevaluator)
4: change
5: notifyChanged(msg)

|affected expressions| times
6: handleEMFEvent(msg)
7: notifyChanged(msg)
8: reevaluate(e, allContextObjectsForE)

|contexts| times

Enriching your models with OCL

Made available under EPL v1.0

51
Scaling up Event Filtering
Effort for event propagation still O(|expressions|)
–

slowed down even if no Notification delivered

Notification #1

Number of OCLExpressions

Enriching your models with OCL

Notification #2

Number of OCLExpressions

Made available under EPL v1.0

52
Idea: Use HashMaps
to map Notification to Set<Adapter>

notifier.eClass() conforms to
Parameter

[a1, a7, a15]

Signature

[a1, a3, a9]

…

…

…

…

Notification:
- notifier
- oldValue
- newValue
- feature
- eventType

Set<Adapter> interested

feature

Set<Adapter> interested

NamedElement.name

[a3, a9, a14]

Call.signature

[a7, a15]

…

…

Enriching your models with OCL

Made available under EPL v1.0

53
Effects of HashMap-Based Eventing
Faster delivery for
Notifications matched
by event filters
Notification #1

Number of OCLExpressions
Enriching your models with OCL

No time increase for
expressions whose filters
don't match a Notification
Notification #2

Number of OCLExpressions
Made available under EPL v1.0

54
Reducing Contexts for Re-Evaluation
●

●

Use partial evaluation to prove value unchanged
● self.name='abc' not affected by name change
from 'x' to 'y'
Use Notification object (notifier,
oldValue, newValue) to navigate “backwards” to
affected context objects
●

self.children.children.name

●

change attribute name on x:Person

●

contexts for re-evaluation:
–

●

x.parents.parents

Tricky for iterators and recursive
operations, but solved.
Enriching your models with OCL

Made available under EPL v1.0

55
Reduce Set of Context Elements
:Tool

one-time setup

{

reevaluator:Adapter

:ImpactAnalyzer

:EventManager

adapterForEventManager
: EventAdapter

e : EObject

1: createFilterForExpression(e)
2: returns eventFilter
3: subscribe(eventFilter, reevaluator)
4: change

|affected expressions| times

5: notifyChanged(msg)

6: handleEMFEvent(msg)
7: notifyChanged(msg)
8: getContextObjects(msg)
9: returns contextObjects
10: reevaluate(e, contextObjects)

|affected contexts| times
Enriching your models with OCL

Made available under EPL v1.0

56
API Usage Example
EventManager eventManager =
EventManagerFactory.eINSTANCE.createEventManagerFor(
editingDomain.getResourceSet());
final OCLExpression invariant = OCL.newInstance().createOCLHelper().
createQuery(“self.signature.parameters->size()=self.arguments->size()“);
final ImpactAnalyzer impactAnalyzer =
ImpactAnalyzerFactory.INSTANCE.createImpactAnalyzer(invariant,
/* notifyOnNewContextElements */ true, oppositeEndFinder);
Adapter adapter = new AdapterImpl() {
@Override
public void notifyChanged(Notification msg) {
// revalidate invariant on context objects delivered by impact analysis:
Collection<EObject> revalidateOn = impactAnalyzer.getContextObjects(msg);
if (revalidateOn != null && !revalidateOn.isEmpty()) {
revalidate(invariant, revalidateOn);
}
}
};
eventManager.subscribe(impactAnalyzer.createFilterForExpression(), adapter);

Enriching your models with OCL

Made available under EPL v1.0

57
Total Re-Evaluation Time in Seconds

Benchmark Context Reduction
(Average Case)
Naive
Event-Filtered (*6 Speed-Up)
Event-Filtered and Context-Reduced
(*1300 Speed-Up vs. Naive,
*220 vs. Event-Filtered-Only)

Number of Model Elements

Enriching your models with OCL

Made available under EPL v1.0

58
Benchmark Context Reduction (Worst Case)

Total Re-Evaluation Time in Seconds

(apply changes to very central elements, referenced by all other model packages)

Naive
Event-Filtered (*2.4 Speed-Up)
Event-Filtered and Context-Reduced
(*27 Speed-Up vs. Naive, *11 vs. Event-Filtered-Only)

Number of Model Elements

Enriching your models with OCL

Made available under EPL v1.0

59
Summary
MDT/OCL originally focussed on Java API
Interactive Modeling Tools require OCL IDE
●

EMF, Xtext, Acceleo, QVTo, OCL support
richer OCL development environment

Extensibility required by QVTo, Acceleo
Efficiency required for serious use
IDE starting to appear
●

Console, Editors

Expect/Demand much more
Contributions welcome
Enriching your models with OCL

Made available under EPL v1.0

60
OCL Resources
●

OCL 2.2 Specification
–

●

●

http://www.omg.org/spec/OCL/2.2

Clause 7 is quite readable (many typos)

The Object Constraint Language:
Getting Your Models Ready For MDA
Jos B. Warmer, Anneke Kleppe
Eclipse MDT/OCL project

http://www.eclipse.org/projects/project_summary.php?projectid=modeling.mdt.ocl
●

Impact analysis
GIT: http://anonymous@www.furcas.org/furcas.git/
SVN: https://www.hpi.uni-potsdam.de/giese/gforge/svn/bp2009
Accounts: https://www.hpi.uni-potsdam.de/giese/gforge/

Enriching your models with OCL

Made available under EPL v1.0

61

Mais conteúdo relacionado

Mais procurados

Scala categorytheory
Scala categorytheoryScala categorytheory
Scala categorytheoryKnoldus Inc.
 
scala.reflect, Eugene Burmako
scala.reflect, Eugene Burmakoscala.reflect, Eugene Burmako
scala.reflect, Eugene BurmakoVasil Remeniuk
 
Programming Android Application in Scala.
Programming Android Application in Scala.Programming Android Application in Scala.
Programming Android Application in Scala.Brian Hsu
 
Stepping Up : A Brief Intro to Scala
Stepping Up : A Brief Intro to ScalaStepping Up : A Brief Intro to Scala
Stepping Up : A Brief Intro to ScalaDerek Chen-Becker
 
Reactive Web Applications with Scala & Liftweb - CodeWeek 2015
Reactive Web Applications with Scala & Liftweb - CodeWeek 2015Reactive Web Applications with Scala & Liftweb - CodeWeek 2015
Reactive Web Applications with Scala & Liftweb - CodeWeek 2015Andrea Zaza
 
Scala: Object-Oriented Meets Functional, by Iulian Dragos
Scala: Object-Oriented Meets Functional, by Iulian DragosScala: Object-Oriented Meets Functional, by Iulian Dragos
Scala: Object-Oriented Meets Functional, by Iulian Dragos3Pillar Global
 
Introductiontoprogramminginscala
IntroductiontoprogramminginscalaIntroductiontoprogramminginscala
IntroductiontoprogramminginscalaAmuhinda Hungai
 
Few simple-type-tricks in scala
Few simple-type-tricks in scalaFew simple-type-tricks in scala
Few simple-type-tricks in scalaRuslan Shevchenko
 
Unraveling the mystery of monads
Unraveling the mystery of monadsUnraveling the mystery of monads
Unraveling the mystery of monadsFaisal Waris
 
Scaladroids: Developing Android Apps with Scala
Scaladroids: Developing Android Apps with ScalaScaladroids: Developing Android Apps with Scala
Scaladroids: Developing Android Apps with ScalaOstap Andrusiv
 

Mais procurados (20)

Scala categorytheory
Scala categorytheoryScala categorytheory
Scala categorytheory
 
scala.reflect, Eugene Burmako
scala.reflect, Eugene Burmakoscala.reflect, Eugene Burmako
scala.reflect, Eugene Burmako
 
Programming Android Application in Scala.
Programming Android Application in Scala.Programming Android Application in Scala.
Programming Android Application in Scala.
 
Scala - core features
Scala - core featuresScala - core features
Scala - core features
 
Scala
ScalaScala
Scala
 
1.2 scala basics
1.2 scala basics1.2 scala basics
1.2 scala basics
 
Stepping Up : A Brief Intro to Scala
Stepping Up : A Brief Intro to ScalaStepping Up : A Brief Intro to Scala
Stepping Up : A Brief Intro to Scala
 
Reactive Web Applications with Scala & Liftweb - CodeWeek 2015
Reactive Web Applications with Scala & Liftweb - CodeWeek 2015Reactive Web Applications with Scala & Liftweb - CodeWeek 2015
Reactive Web Applications with Scala & Liftweb - CodeWeek 2015
 
Scala - brief intro
Scala - brief introScala - brief intro
Scala - brief intro
 
Scala jargon cheatsheet
Scala jargon cheatsheetScala jargon cheatsheet
Scala jargon cheatsheet
 
Scala: Object-Oriented Meets Functional, by Iulian Dragos
Scala: Object-Oriented Meets Functional, by Iulian DragosScala: Object-Oriented Meets Functional, by Iulian Dragos
Scala: Object-Oriented Meets Functional, by Iulian Dragos
 
Introductiontoprogramminginscala
IntroductiontoprogramminginscalaIntroductiontoprogramminginscala
Introductiontoprogramminginscala
 
Getting Started With Scala
Getting Started With ScalaGetting Started With Scala
Getting Started With Scala
 
Scala on Android
Scala on AndroidScala on Android
Scala on Android
 
All about scala
All about scalaAll about scala
All about scala
 
camel-scala.pdf
camel-scala.pdfcamel-scala.pdf
camel-scala.pdf
 
Few simple-type-tricks in scala
Few simple-type-tricks in scalaFew simple-type-tricks in scala
Few simple-type-tricks in scala
 
Unraveling the mystery of monads
Unraveling the mystery of monadsUnraveling the mystery of monads
Unraveling the mystery of monads
 
Scala cheatsheet
Scala cheatsheetScala cheatsheet
Scala cheatsheet
 
Scaladroids: Developing Android Apps with Scala
Scaladroids: Developing Android Apps with ScalaScaladroids: Developing Android Apps with Scala
Scaladroids: Developing Android Apps with Scala
 

Semelhante a Enriching your models with OCL

OCL Integration and Code Generation
OCL Integration and Code GenerationOCL Integration and Code Generation
OCL Integration and Code GenerationEdward Willink
 
Safe navigation in OCL
Safe navigation in OCLSafe navigation in OCL
Safe navigation in OCLEdward Willink
 
Embedded OCL Integration and Debugging
Embedded OCL Integration and DebuggingEmbedded OCL Integration and Debugging
Embedded OCL Integration and DebuggingEdward Willink
 
Formally Defining and Iterating Infinite Models (MODELS 2012)
Formally Defining and Iterating Infinite Models (MODELS 2012)Formally Defining and Iterating Infinite Models (MODELS 2012)
Formally Defining and Iterating Infinite Models (MODELS 2012)Benoit Combemale
 
Enriching EMF Models with Scala (quick overview)
Enriching EMF Models with Scala (quick overview)Enriching EMF Models with Scala (quick overview)
Enriching EMF Models with Scala (quick overview)Filip Krikava
 
OCL 2019 Keynote Retrospective and Prospective
OCL 2019 Keynote Retrospective and ProspectiveOCL 2019 Keynote Retrospective and Prospective
OCL 2019 Keynote Retrospective and ProspectiveEdward Willink
 
Modeling the OCL Standard Library
Modeling the OCL Standard LibraryModeling the OCL Standard Library
Modeling the OCL Standard LibraryEdward Willink
 
Eclipse workshop presentation (March 2016)
Eclipse workshop presentation (March 2016)Eclipse workshop presentation (March 2016)
Eclipse workshop presentation (March 2016)Miguel Pardal
 
Eclipse workshop presentation
Eclipse workshop presentationEclipse workshop presentation
Eclipse workshop presentationMiguel Pardal
 
OclApunteNavegacion.ppt
OclApunteNavegacion.pptOclApunteNavegacion.ppt
OclApunteNavegacion.pptClaudiaNaveda2
 
Developing a new Epsilon Language through Annotations: TestLang
Developing a new Epsilon Language through Annotations: TestLangDeveloping a new Epsilon Language through Annotations: TestLang
Developing a new Epsilon Language through Annotations: TestLangAntonio García-Domínguez
 
Design patterns illustrated-2015-03
Design patterns illustrated-2015-03Design patterns illustrated-2015-03
Design patterns illustrated-2015-03Herman Peeren
 
New c sharp3_features_(linq)_part_i
New c sharp3_features_(linq)_part_iNew c sharp3_features_(linq)_part_i
New c sharp3_features_(linq)_part_iNico Ludwig
 
Eclipse Overview
Eclipse Overview Eclipse Overview
Eclipse Overview Lars Vogel
 
Design patterns in javascript
Design patterns in javascriptDesign patterns in javascript
Design patterns in javascriptAyush Sharma
 

Semelhante a Enriching your models with OCL (20)

OCL Integration and Code Generation
OCL Integration and Code GenerationOCL Integration and Code Generation
OCL Integration and Code Generation
 
Safe navigation in OCL
Safe navigation in OCLSafe navigation in OCL
Safe navigation in OCL
 
Embedded OCL Integration and Debugging
Embedded OCL Integration and DebuggingEmbedded OCL Integration and Debugging
Embedded OCL Integration and Debugging
 
Formally Defining and Iterating Infinite Models (MODELS 2012)
Formally Defining and Iterating Infinite Models (MODELS 2012)Formally Defining and Iterating Infinite Models (MODELS 2012)
Formally Defining and Iterating Infinite Models (MODELS 2012)
 
Aligning OCL and UML
Aligning OCL and UMLAligning OCL and UML
Aligning OCL and UML
 
The OCLforUML Profile
The OCLforUML ProfileThe OCLforUML Profile
The OCLforUML Profile
 
Enriching EMF Models with Scala (quick overview)
Enriching EMF Models with Scala (quick overview)Enriching EMF Models with Scala (quick overview)
Enriching EMF Models with Scala (quick overview)
 
OCL 2.5 plans
OCL 2.5 plansOCL 2.5 plans
OCL 2.5 plans
 
OCL 2019 Keynote Retrospective and Prospective
OCL 2019 Keynote Retrospective and ProspectiveOCL 2019 Keynote Retrospective and Prospective
OCL 2019 Keynote Retrospective and Prospective
 
Modeling the OCL Standard Library
Modeling the OCL Standard LibraryModeling the OCL Standard Library
Modeling the OCL Standard Library
 
Eclipse workshop presentation (March 2016)
Eclipse workshop presentation (March 2016)Eclipse workshop presentation (March 2016)
Eclipse workshop presentation (March 2016)
 
Eclipse workshop presentation
Eclipse workshop presentationEclipse workshop presentation
Eclipse workshop presentation
 
OclApunteNavegacion.ppt
OclApunteNavegacion.pptOclApunteNavegacion.ppt
OclApunteNavegacion.ppt
 
Developing a new Epsilon Language through Annotations: TestLang
Developing a new Epsilon Language through Annotations: TestLangDeveloping a new Epsilon Language through Annotations: TestLang
Developing a new Epsilon Language through Annotations: TestLang
 
Eclipse OCL Summary
Eclipse OCL SummaryEclipse OCL Summary
Eclipse OCL Summary
 
Design patterns illustrated-2015-03
Design patterns illustrated-2015-03Design patterns illustrated-2015-03
Design patterns illustrated-2015-03
 
New c sharp3_features_(linq)_part_i
New c sharp3_features_(linq)_part_iNew c sharp3_features_(linq)_part_i
New c sharp3_features_(linq)_part_i
 
EduSymp 2022 slides (The Epsilon Playground)
EduSymp 2022 slides (The Epsilon Playground)EduSymp 2022 slides (The Epsilon Playground)
EduSymp 2022 slides (The Epsilon Playground)
 
Eclipse Overview
Eclipse Overview Eclipse Overview
Eclipse Overview
 
Design patterns in javascript
Design patterns in javascriptDesign patterns in javascript
Design patterns in javascript
 

Mais de University of York

A DSTL to bridge concrete and abstract syntax
A DSTL to bridge concrete and abstract syntaxA DSTL to bridge concrete and abstract syntax
A DSTL to bridge concrete and abstract syntaxUniversity of York
 
An OCL-based bridge from CS to AS
An OCL-based bridge from CS to ASAn OCL-based bridge from CS to AS
An OCL-based bridge from CS to ASUniversity of York
 
Enhancing Xtext for General Purpose Languages
Enhancing Xtext for General Purpose LanguagesEnhancing Xtext for General Purpose Languages
Enhancing Xtext for General Purpose LanguagesUniversity of York
 
Automatic Application of Visitors to Evolving Domain-Specific Languages
Automatic Application of Visitors to Evolving Domain-Specific LanguagesAutomatic Application of Visitors to Evolving Domain-Specific Languages
Automatic Application of Visitors to Evolving Domain-Specific LanguagesUniversity of York
 
Reusing FEFEM in form-based model editor generation.
Reusing FEFEM in form-based model editor generation.Reusing FEFEM in form-based model editor generation.
Reusing FEFEM in form-based model editor generation.University of York
 

Mais de University of York (6)

A DSTL to bridge concrete and abstract syntax
A DSTL to bridge concrete and abstract syntaxA DSTL to bridge concrete and abstract syntax
A DSTL to bridge concrete and abstract syntax
 
An OCL-based bridge from CS to AS
An OCL-based bridge from CS to ASAn OCL-based bridge from CS to AS
An OCL-based bridge from CS to AS
 
Visitors Framework Generator
Visitors Framework GeneratorVisitors Framework Generator
Visitors Framework Generator
 
Enhancing Xtext for General Purpose Languages
Enhancing Xtext for General Purpose LanguagesEnhancing Xtext for General Purpose Languages
Enhancing Xtext for General Purpose Languages
 
Automatic Application of Visitors to Evolving Domain-Specific Languages
Automatic Application of Visitors to Evolving Domain-Specific LanguagesAutomatic Application of Visitors to Evolving Domain-Specific Languages
Automatic Application of Visitors to Evolving Domain-Specific Languages
 
Reusing FEFEM in form-based model editor generation.
Reusing FEFEM in form-based model editor generation.Reusing FEFEM in form-based model editor generation.
Reusing FEFEM in form-based model editor generation.
 

Último

Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 

Último (20)

Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 

Enriching your models with OCL

  • 1. Enriching Your Models with OCL Adolfo Sánchez-Barbudo Herrera, Open Canarias Axel Uhl, SAP Edward Willink, MDT/OCL Project Lead 3rd November 2010 Made available under EPL v1.0
  • 2. Overview MDT/OCL team ● Why and When OCL ● Introduction to OCL ● OCL within Eclipse ● OCL Use Cases, coming soon SAP ● Scaling up OCL at SAP Enriching your models with OCL Made available under EPL v1.0 2
  • 3. Follow Along http://www.eclipsecon.org/summiteurope2010/sessions/?page=sessions&id=1710 links to slides and to zip file comprising, model,edit,editor,diagram projects MDT/OCL 3.0.1 Examples and Editors ● Install ● Import ... Existing Projects from Archive – ● ESEExampleTree/model/People1.ecore Run nested Eclipse, Import ESEExampleTree – ESEExampleTree/model/default.people_diagram Enriching your models with OCL Made available under EPL v1.0 3
  • 4. How Much OCL? None ● Very simple modeling ● Java augmented modeling A little ● OCL (and Java) augmented modeling A lot ● OCL as a powerful formal specification language – ● OCL as the foundation of a transformation language – ● OMG's UML, OCL, QVT, ... specifications MOFM2T (Acceleo), QVT OCL as a portable implementation language Enriching your models with OCL Made available under EPL v1.0 4
  • 5. UML State Machines ● Need to specify behavior ● amber when End of Stop or Start of Stop ● transition when signal received/time elapsed Enriching your models with OCL Made available under EPL v1.0 5
  • 6. UML Solutions UML 1.x Use your favourite 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 values Enriching your models with OCL Made available under EPL v1.0 6
  • 7. Simple Meta-Modeling Graphics ● Box – ● Compartment – ● Enriching your models with OCL Association Decoration – Example Family Tree Meta-Model Ecore Diagram (similar to UML Class Diagram) Property, operation Line – ● Class, enumeration Composition, navigability Text ● Name, type, stereotype ● Multiplicity Made available under EPL v1.0 7
  • 8. Richer Meta-Modelling ● Implicit constraints ● ● ● Up to 2 parents MALE/FEMALE gender Arbitrary constraints ● ● 1 MALE, 1 FEMALE parent ● Enriching your models with OCL At least 5 characters in name Self is not an ancestor of self Made available under EPL v1.0 8
  • 9. Example Family Tree Model Simple GMF Diagram Editor ESEExampleTree/model/default.people_diagram Enriching your models with OCL Made available under EPL v1.0 9
  • 10. Simple Query Evaluation Window->Show View->Other... Console Console: New: Interactive OCL Select Zeus as the Model Context (in any model editor) Type children then carriage return Enriching your models with OCL Made available under EPL v1.0 10
  • 11. OCL Principles ● 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 generalization Enriching your models with OCL Made available under EPL v1.0 11
  • 12. OCL Object Types ● Primitive Types – – Boolean, String Real, Integer, UnlimitedNatural ● ● unlimited; no float/double etc distinction Bottom Types – – ● OclVoid: any value can be null OclInvalid: any value can be invalid Top Type – OclAny: every OCL and user type conform to OclAny type. Enriching your models with OCL Made available under EPL v1.0 12
  • 13. Mathematical Operators Infix: +, -, *, / and, or, xor, implies =, <>, <, >, <=, >= Prefix: not, 4.0 * -5 'a' + 'b' Operators: mod, div, max, min, ... 4.max(5) Enriching your models with OCL Made available under EPL v1.0 nb =, <> 13
  • 14. OCL Expressions ● If Expressions if gender = Gender::MALE then 'he' else 'she' endif ● Let Expressions let jack : Person = child('Jack'), jill : Person = child('Jill') in jack <> null and jill <> null Enriching your models with OCL Made available under EPL v1.0 14
  • 15. More Complex Query Selecting Poseidon defines the implicit context variable self : Person = Poseidon Enriching your models with OCL Made available under EPL v1.0 15
  • 16. Object Navigation Properties ● self.name or just name (cf. this.getName() or getName()) Operations ● self.child('John') or just child('John') (cf. this.child('John') or child('John')) Enriching your models with OCL Made available under EPL v1.0 16
  • 17. The OCLinEcore Editor Select model/People1.ecore Open With... OCLinEcore Enriching your models with OCL Made available under EPL v1.0 17
  • 18. Example Validation Failure Open model/People1.xmi with Sample Reflective Ecore Editor Select Universe, Right button menu, Validate Enriching your models with OCL Made available under EPL v1.0 18
  • 19. Multiplicities and Collections Meta-models specify multiplicities – – ● children : Person[*] {ordered,unique} parents : Person[0..2] {unique} multiplicities are specification concepts; not objects Implementations (e.g. Ecore) reify multiplicities – ● getChildren() returns a UniqueEList<Person> 'many' properties have extra implementation objects – – getName() getChildren().get(2) setName(newName) getChildren().add(newChild) OCL needs more than just UML multiplicities Enriching your models with OCL Made available under EPL v1.0 19
  • 20. OCL 2.0 Collections Typed Collections partially reify multiplicities Collection(T) Non-Unique Unique Unordered Bag(T) Set(T) Ordered Sequence(T) OrderedSet(T) Collections are different to objects Navigation from a Collection uses -> – [Navigation from an Object (OclAny) uses .] Collections have type parameters Collections have useful operations Collections have very useful iterations Enriching your models with OCL Made available under EPL v1.0 20
  • 21. Example Collection Operations Collection::size() self.children->size() 'get' Sequence::at(Integer) self.children->at(1) – nb 1 is the first index, size() is the last 'add' Collection(T)::including(T) : Collection(T) – returns a new collection with added content 'contains' Collection(T)::includes(T) : Boolean – tests existing content Enriching your models with OCL Made available under EPL v1.0 21
  • 22. Collection::select iteration ● Children self.children ● Sons self.children->select(gender = Gender::MALE) self.children->select(child | child.gender = Gender::MALE) self.children->select(child : Person | child.gender = Gender::MALE) ● select(iterator : type | body) – ● reject(iterator : type | body) – ● filters to select elements for which the body is true filters to reject elements for which the body is true cf multi-line Java loop Enriching your models with OCL Made available under EPL v1.0 22
  • 23. Collection::collect iteration ● Children self.children ● Grandchildren self.children->collect(children) self.children->collect(child | child.children) self.children->collect(child : Person | child.children) ● collect(iterator : type | body) – ● creates a new collection comprising all the bodies any, exists, forAll, isUnique, iterate, one, Enriching your models with OCL Made available under EPL v1.0 23
  • 24. OCL Navigation Operators anObject. ... aCollection-> ... object navigation collection navigation Object Navigation ? . -> Collection ? Navigation Shorthands aCollection. ... anObject-> ... Enriching your models with OCL implicit collect implicit collection Made available under EPL v1.0 24
  • 25. Implicit Collect Query parents.parents = parents->collect(parents) 3 symbols, compared to 4 lines of Java 4 grandparents, but not all different! Enriching your models with OCL Made available under EPL v1.0 25
  • 26. Cleaned up query parents.parents->asSet()->sortedBy(name) ->asSet() converts to Set(Person), removes duplicates ->sortedBy(name) alphabeticizes Enriching your models with OCL Made available under EPL v1.0 26
  • 27. Implicit Collection Conversion . -> Object Navigation Implicit Collection Collection Implicit collect() Navigation self->notEmpty() ● Standard OCL idiom – – Converts self (if an object) to a Collection of self If self is a defined object ● – If self is an undefined object (null) ● – Implicit collection is not empty - true Implicit collection is empty - false If self is an error (invalid) ● Implicit collection is also an error - invalid Enriching your models with OCL Made available under EPL v1.0 27
  • 28. Collection::closure iteration ● children, grandchildren, greatgrandchildren etc self->closure(children) Implicit collection of self, then closure of all children [ closure in MDT/OCL 1.2, probably in OMG OCL 2.3 ] ● Enriching your models with OCL Made available under EPL v1.0 28
  • 29. OCL as Implementation any(x) iteration selects an arbitrary element for which x is true. Enriching your models with OCL Made available under EPL v1.0 29
  • 30. Derived Properties For Hera invariant MixedGenderParents: father.gender <> mother.gender; fails because father is null and mother is null Enriching your models with OCL Made available under EPL v1.0 30
  • 31. Other OCL Capabilities No time to mention ● Other iterators, operations ● Tuples ● Association Classes/Qualifiers ● @pre values ● Messages ● States Enriching your models with OCL Made available under EPL v1.0 31
  • 32. OMG OCL Progress OCL 2.2 (current) Collections are objects! – – – Collection conforms to OclAny No need for Collection/Object polymorphic operations Collections can mix Object/Collection content ? OCL 2.4 Specification defined by models – – – Auto-generated by Acceleo Fix too many consistency/typo/realizability issues Aligned with UML 2.4, MOF 2.4, XMI 2.4 Eclipse committers active on OMG RTF Enriching your models with OCL Made available under EPL v1.0 32
  • 33. Eclipse MDT/OCL ● OMG OCL 1.x EMFT/OCL 1.0 Original code contribution by IBM ● Java callable API – Parse/evaluate OCL 1.x against Ecore meta-models OMG OCL 2.2 MDT/OCL 3.0 Ecore or UML meta-models ● OCL 2.0 (in so far as possible) ● OMG OCL 2.0 MDT/OCL 1.2 ● Example Interactive Console ● towards OCL 2.2 ● Example Xtext editors (Ecore only) Enriching your models with OCL Made available under EPL v1.0 33
  • 34. Validation History Eclipse 3.2 Use of OCL to define model validation ● EMF Validation Framework – ● Eclipse 3.3 EMF, OCL EAnnotations – – Eclipse 3.6 EMF 2.6 MDT/OCL 3.0 ● Embed OCL in XML CDATA Embed OCL in EAnnotation Genmodel to integrate Delegates – – – Embed OCL in EAnnotation EObject.eInvoke() for dynamic invocation OCLinEcore editor for semi-validated editing Enriching your models with OCL Made available under EPL v1.0 34
  • 35. OCLinEcore Editor ● Open with -> OCLinEcore ● Save As *.ecore – ● Save As *.oclinecore – ● Loses formatting and comments Text file preserves comments Useful for plain Ecore too: – – Printable/reviewable text Searchable/replaceable text Enriching your models with OCL Made available under EPL v1.0 35
  • 36. Validation in Sample Ecore Editor OCLinEcore editor maintains EAnnotations automatically OCLinEcore editor provides OCL syntax checking OCLinEcore editor will provide OCL semantic checking Enriching your models with OCL Made available under EPL v1.0 36
  • 37. (Example) Tools and Tips OCLinEcore editor for Ecore/embedded OCL CompleteOCL editor for OCL documents EssentialOCL editor for OCL Expressions (Papyrus) OCL Interactive Console – – Invaluable ability to practice non-trivial expressions Page Up/Page Down to reuse expressions Meta-model reload after change Genmodel settings for embedded OCL Enriching your models with OCL Made available under EPL v1.0 37
  • 38. EMF Dynamic Instances Create/update Ecore meta-model Create XMI instance of EClass in meta-model Update XMI model, validate OCL constraints Enriching your models with OCL Made available under EPL v1.0 38
  • 39. Meta-model Update UML meta-model realizes My.uml Ecore meta-model conformsTo My.ecore Model data.my Edit UML/Ecore meta-model in UML/Ecore editor – – manual export of UML to Ecore in workspace manual save of Ecore to workspace Create Dynamic Instance/Load Model in editor – validate/evaluate OCL constraints EMF does not support meta-model mutation – – Model.eClass() reverts to an unresolved proxy must exit and re-enter model editor Enriching your models with OCL Made available under EPL v1.0 39
  • 40. Genmodel settings for OCL If not set to true ● MDT/OCL 3.0.0 OCL operation bodies not invoked ● MDT/OCL 3.0.1 Error Log as dynamic fallback used Enriching your models with OCL Made available under EPL v1.0 40
  • 41. Eclipse MDT/OCL Futures 3.1 Core (Indigo) – Minor maintenance 3.1 Examples (Indigo) – – – – New Ecore/UML blind pivot meta-model Extensible modelled Standard Library Xtext editors Super-compliant - anticipating OMG OCL resolutions 4.0 Core + Tools + Examples (Indigo+1) – 3.1 Examples promoted to Core or Tools ● – preserved external APIs, significant revision of internal APIs OCL to Java code generation Enriching your models with OCL Made available under EPL v1.0 41
  • 42. Which OCL Use Cases work When Validate Evaluate Console Editor Static Java For Ecore 1.0 1.0 1.0 Examples 3.0 Examples Static Java For UML 1.2 1.2 3.1 Examples 3.1 Examples Complete OCL For Ecore 3.1 Examples 3.1 Examples 3.1 Examples 3.0 Examples Complete OCL For UML 3.1 Examples 3.1 Examples 3.1 Examples 3.1 Examples Embedded OCL in Ecore 3.0 3.0 3.0 Examples 3.0 Examples Embedded OCL in UML 3.1 Examples 3.1 Examples 3.1 Examples 3.1 Examples Released in Helios Example functionality in Helios Example functionality in Indigo, release in Indigo+1 Enriching your models with OCL Made available under EPL v1.0 42
  • 43. OCL 'Standard' Library Problems: OMG – – – library is not a model uses non-UML concepts (Iterator) no reflection for OclAny::oclType() Problems: MDT/OCL – – – hard coded, difficult to extend UML/Ecore differences, long generic template lists Ecore/EMOF discrepancies : EClass/Class Solution: OMG – library is a model defined by the new OCL meta-model Benefit: MDT/OCL – variants, extensible, unified, compliant Enriching your models with OCL Made available under EPL v1.0 43
  • 44. OCL Models Problems: OMG – – – – OCL is not fully UML-aligned OCL modifies UML models (OclAny) Complete OCL modifies UML models OCL requires a modified sub-UML @ run-time Problems: MDT/OCL – – UML/Ecore implementation differences, Ecore extension Ecore/EMOF discrepancies Solution: OMG – – Pivot meta-model defines UML @ run-time Pivot model realises OCL-defined merges Benefit: MDT/OCL – unified, compliant, Ecore/EMOF hidden Enriching your models with OCL Made available under EPL v1.0 44
  • 45. Evaluation Problems: MDT/OCL: – – – – OCL interpreted by Java OperationCallExp visit is very inefficient Slightly hard to extend for QVTo, Acceleo OCL within genmodelled Java is just a String ● significant first time parsing costs Solution: MDT/OCL – – – OCL to Java code generation Library model references a Java class per feature Code efficiency Benefit: MDT/OCL – – extensible, faster (10 to 100 times ... iteration strategies) Java in genmodelled Java Enriching your models with OCL Made available under EPL v1.0 45
  • 46. Beyond OCL OMG OCL is a powerful expression language ● Declarative, First Order Predicate Calculus/Logic ● Model-oriented, UML navigation, multiplicities, ... Formal language supports formal analysis analysis supports optimisation OCL's usefulness calls for scalable implementation Enriching your models with OCL Made available under EPL v1.0 46
  • 47. The Re-Evaluation Problem • A set of OCL expressions • A set of model elements • A model change notification • • Which of the OCL expressions may have changed its value on which context elements? Naïve approach ● re-evaluate all expressions for all their contexts ● takes O(|expressions| * |modelElements|) Enriching your models with OCL Made available under EPL v1.0 47
  • 48. Example self.signature.parameters->size() = self.arguments->size() Enriching your models with OCL Made available under EPL v1.0 48
  • 49. Naïve Re-Evaluation Sequence :Tool reevaluator:Adapter e : EObject a w t's ha T oo t y ! w lo s |expressions| times 1: change 2: notifyChanged(msg) 3: reevaluateAllExpressionsOnAllTheirContexts |contexts| times Enriching your models with OCL Made available under EPL v1.0 49
  • 50. Idea: Find out from Notification which OCLExpressions may have changed Example: OCLExpression self.arguments->size() = self.signature.parameters->size() generates Notification filter (containment AND ((new value filter incl subs for: Call) OR (old value filter incl subs for: Call))) OR ((wantedClass conformsTo: Signature) AND (feature: parameters)) OR ((wantedClass conformsTo: Call) AND (feature: signature)) OR ((wantedClass conformsTo: Call) AND (feature: arguments)) Many expressions cause – many adapters with one (often non-trivial) Notification filter each – which need evaluation for each change Notification – Enriching your models with OCL Made available under EPL v1.0 50
  • 51. Filter Events for OCLExpressions :Tool one-time setup { reevaluator:Adapter :ImpactAnalyzer :EventManager adapterForEventManager : EventAdapter e : EObject 1: createFilterForExpression(e) 2: returns eventFilter 3: subscribe(eventFilter, reevaluator) 4: change 5: notifyChanged(msg) |affected expressions| times 6: handleEMFEvent(msg) 7: notifyChanged(msg) 8: reevaluate(e, allContextObjectsForE) |contexts| times Enriching your models with OCL Made available under EPL v1.0 51
  • 52. Scaling up Event Filtering Effort for event propagation still O(|expressions|) – slowed down even if no Notification delivered Notification #1 Number of OCLExpressions Enriching your models with OCL Notification #2 Number of OCLExpressions Made available under EPL v1.0 52
  • 53. Idea: Use HashMaps to map Notification to Set<Adapter> notifier.eClass() conforms to Parameter [a1, a7, a15] Signature [a1, a3, a9] … … … … Notification: - notifier - oldValue - newValue - feature - eventType Set<Adapter> interested feature Set<Adapter> interested NamedElement.name [a3, a9, a14] Call.signature [a7, a15] … … Enriching your models with OCL Made available under EPL v1.0 53
  • 54. Effects of HashMap-Based Eventing Faster delivery for Notifications matched by event filters Notification #1 Number of OCLExpressions Enriching your models with OCL No time increase for expressions whose filters don't match a Notification Notification #2 Number of OCLExpressions Made available under EPL v1.0 54
  • 55. Reducing Contexts for Re-Evaluation ● ● Use partial evaluation to prove value unchanged ● self.name='abc' not affected by name change from 'x' to 'y' Use Notification object (notifier, oldValue, newValue) to navigate “backwards” to affected context objects ● self.children.children.name ● change attribute name on x:Person ● contexts for re-evaluation: – ● x.parents.parents Tricky for iterators and recursive operations, but solved. Enriching your models with OCL Made available under EPL v1.0 55
  • 56. Reduce Set of Context Elements :Tool one-time setup { reevaluator:Adapter :ImpactAnalyzer :EventManager adapterForEventManager : EventAdapter e : EObject 1: createFilterForExpression(e) 2: returns eventFilter 3: subscribe(eventFilter, reevaluator) 4: change |affected expressions| times 5: notifyChanged(msg) 6: handleEMFEvent(msg) 7: notifyChanged(msg) 8: getContextObjects(msg) 9: returns contextObjects 10: reevaluate(e, contextObjects) |affected contexts| times Enriching your models with OCL Made available under EPL v1.0 56
  • 57. API Usage Example EventManager eventManager = EventManagerFactory.eINSTANCE.createEventManagerFor( editingDomain.getResourceSet()); final OCLExpression invariant = OCL.newInstance().createOCLHelper(). createQuery(“self.signature.parameters->size()=self.arguments->size()“); final ImpactAnalyzer impactAnalyzer = ImpactAnalyzerFactory.INSTANCE.createImpactAnalyzer(invariant, /* notifyOnNewContextElements */ true, oppositeEndFinder); Adapter adapter = new AdapterImpl() { @Override public void notifyChanged(Notification msg) { // revalidate invariant on context objects delivered by impact analysis: Collection<EObject> revalidateOn = impactAnalyzer.getContextObjects(msg); if (revalidateOn != null && !revalidateOn.isEmpty()) { revalidate(invariant, revalidateOn); } } }; eventManager.subscribe(impactAnalyzer.createFilterForExpression(), adapter); Enriching your models with OCL Made available under EPL v1.0 57
  • 58. Total Re-Evaluation Time in Seconds Benchmark Context Reduction (Average Case) Naive Event-Filtered (*6 Speed-Up) Event-Filtered and Context-Reduced (*1300 Speed-Up vs. Naive, *220 vs. Event-Filtered-Only) Number of Model Elements Enriching your models with OCL Made available under EPL v1.0 58
  • 59. Benchmark Context Reduction (Worst Case) Total Re-Evaluation Time in Seconds (apply changes to very central elements, referenced by all other model packages) Naive Event-Filtered (*2.4 Speed-Up) Event-Filtered and Context-Reduced (*27 Speed-Up vs. Naive, *11 vs. Event-Filtered-Only) Number of Model Elements Enriching your models with OCL Made available under EPL v1.0 59
  • 60. Summary MDT/OCL originally focussed on Java API Interactive Modeling Tools require OCL IDE ● EMF, Xtext, Acceleo, QVTo, OCL support richer OCL development environment Extensibility required by QVTo, Acceleo Efficiency required for serious use IDE starting to appear ● Console, Editors Expect/Demand much more Contributions welcome Enriching your models with OCL Made available under EPL v1.0 60
  • 61. OCL Resources ● OCL 2.2 Specification – ● ● http://www.omg.org/spec/OCL/2.2 Clause 7 is quite readable (many typos) The Object Constraint Language: Getting Your Models Ready For MDA Jos B. Warmer, Anneke Kleppe Eclipse MDT/OCL project http://www.eclipse.org/projects/project_summary.php?projectid=modeling.mdt.ocl ● Impact analysis GIT: http://anonymous@www.furcas.org/furcas.git/ SVN: https://www.hpi.uni-potsdam.de/giese/gforge/svn/bp2009 Accounts: https://www.hpi.uni-potsdam.de/giese/gforge/ Enriching your models with OCL Made available under EPL v1.0 61