SlideShare una empresa de Scribd logo
1 de 119
Enrich Your Models with OCL Edward Willink,  Thales MDT/OCL Project Lead Axel Uhl,  SAP 21st March 2011
Part 1: OCL in isolation Installation Instructions OCL Basic Principles exercises OCL Collections and Iterators exercises OCL tools and usage exercises OCL in Java - analyzable language
Part 2: OCL beyond OCL State Machine Example ,[object Object]
OCLinEcore - integrated validation language exercises ,[object Object],[object Object],[object Object],[object Object]
Tutorial Material ,[object Object],http://www.eclipsecon.org/2011/sessions/?page=sessions&id=2271 ,[object Object]
link to a ZIP of ZIPs (only one file allowed) ,[object Object],[object Object],(http:// www.eclipse.org /modeling/mdt/ocl/docs/publications/EclipseCon2011Tutorial/MainWorkspaceProjects.zip) ,[object Object],(http://www.eclipse.org/modeling/mdt/ocl/docs/publications/EclipseCon2011Tutorial/RuntimeWorkspaceProjects.zip) ,[object Object]
Preparation - Indigo M6 Platform ,[object Object],[object Object],[object Object],C:oolsclipse.7M6EclipseConclipse.exe   -data C:/EclipseCon/Workspace -vmargs -Xmx1g   -XX:PermSize=64M -XX:MaxPermSize=128M
Preparation - Indigo M6 Projects ,[object Object],Indigo - http://download.eclipse.org/releases/indigo (after 18 Mar)  Indigo - http://download.eclipse.org/releases/staging (before) ,[object Object]
Modeling->Graphical Modeling Framework (GMF) Runtime
Modeling->OCL Examples and Editors
Modeling->Operational QVT SDK
Modeling->UML2 Extender SDK ,[object Object],[object Object],[object Object]
Next ... Restart Now
Preparation - Indigo M6a Updates ,[object Object]
no help for adverse SWT/Modeling interaction  ,[object Object],http://download.eclipse.org/modeling/mdt/ocl/updates/milestones or USB stick:  mdt-ocl-Update-3.1.0M6a.zip ,[object Object]
Preparation - Main Workspace ,[object Object]
Next ,[object Object],http://www.eclipse.org/modeling/mdt/ocl/docs/publications/EclipseCon2011Tutorial/MainWorkspaceProjects.zip ,[object Object]
0 errors
98 warnings
Preparation - Runtime Eclipse ,[object Object],-Xms40m -Xmx512m   -XX:PermSize=64M -XX:MaxPermSize=128M ,[object Object]
Select the "Arguments" tab ,[object Object],[object Object]
Preparation - Runtime Workspace ,[object Object]
Next ,[object Object],[object Object]
2 errors
3 warnings
Models ,[object Object],[object Object],[object Object],[object Object]
Xtext editors ,[object Object],[object Object]
Rules ,[object Object]
password must contain only letters and numbers ,[object Object],[object Object]
semantic validation for complex rules ,[object Object],[object Object],[object Object],[object Object]
Behaviors ,[object Object]
changes occur ,[object Object],[object Object],[object Object]
M2M: OMG QVT, Eclipse QVTo, ATL, Epsilon
M2T: OMG MOFM2T, Eclipse Acceleo
Object Constraint Language ,[object Object],[object Object]
Simple Meta-Modeling Graphics ,[object Object],Text ,[object Object]
Multiplicity Example Family Tree Meta-Model Ecore Diagram (similar to UML Class Diagram)
Richer Meta-Modelling ,[object Object]
MALE/FEMALE gender ,[object Object]
1 MALE, 1 FEMALE parent
Self is not  an ancestor  of self
Example Family Tree Model Simple GMF Diagram Editor Runtime Workspace: ESEExampleTree/model/default.people_diagram
Simple Query Evaluation Window->Show View->Other... Console Console: New: Interactive Xtext OCL Select  Zeus  as the Model Context (in any model editor) Type  children  then carriage return
OCL Principles ,[object Object],∀ x ∈ y ∃ z(x) ,[object Object]
side effect free, no model changes, atomic execution
strongly typed, using UML generalization
Primitive Types and Literals Java (implementation) OCL (specification) boolean,Boolean,true,false Boolean,true,false short,int,long,Integer,BigInteger Integer , UnlimitedNatural float, double, BigDecimal Real Character, String, 'c',  " line " String, 'c',  ' line ' Object,this,null OclAny, self ,null Exception invalid Integer value value : Integer Java: practical implementation language OCL: simpler, idealistic, specification language
Mathematical Operators Java (implementation) OCL (specification) +, -, *, / +, -, *, / !, &&, ||, ^ not, and, or, xor, implies <, >, <=, >= <, >, <=, >= ==, != = , <> Math.max(4,5) 4.max(5) if  (a) b  else  c; if  a  then  b  else  c  endif Integer value = 5; doSomething(value); let  value : Integer = 5 in  doSomething(value)
More Complex Query Selecting  Hera  defines the implicit context variable self : Person =  Hera
Object Navigation Properties ,[object Object],Operations ,[object Object]
OCL in context ,[object Object]
adds values to model usage ,[object Object],[object Object],[object Object]
transforms the capabilties ,[object Object]
EMF Delegates (Helios) ,[object Object],[object Object]
Setting Delegate for EStructuralFeature initial value
Example Validation Delegate
The OCLinEcore Editor OCLinEcore editor maintains EAnnotations automatically OCLinEcore editor provides OCL syntax checking OCLinEcore editor will provide OCL semantic checking
OCLinEcore Editor ,[object Object]
Save As *.ecore ,[object Object],[object Object],[object Object],[object Object],[object Object]
Searchable/replaceable text
Example Validation Failure Open ESEExampleTree/model/People1.xmi in Main Eclipse, with Sample Reflective Ecore Editor Select Universe, Right button menu, Validate
Evaluator, OCLinEcore exercises ,[object Object]
determine the number of letters in Hephaestus ,[object Object],[object Object],[object Object]
revalidate
Multiplicities and Collections Meta-models specify multiplicities ,[object Object]
parents : Person[0..2] {unique} ,[object Object],Implementations (e.g. Ecore) reify multiplicities ,[object Object]
getChildren().get(2)  getChildren().add(newChild) OCL needs more than just UML multiplicities
OCL 2.0 Collections Typed Collections partially reify multiplicities Collections are different to objects Navigation from a Collection uses  -> ,[object Object],Collections have type parameters Collections have useful operations Collections have very useful iterations Collections are immutable Collection(T) Unordered Ordered Non-Unique Bag(T) Sequence(T) Unique Set(T) OrderedSet(T)
Example Collection Operations Collection::size()  self.children->size() 'get' Sequence::at(Integer)  self.children->at(1) ,[object Object],'add' Collection(T)::including(T) : Collection(T) ,[object Object],'contains' Collection(T)::includes(T) : Boolean ,[object Object]
Collection::select iteration ,[object Object],self.children ,[object Object],self.children->select(gender = Gender::MALE) self.children->select(child | child.gender = Gender::MALE) self.children->select(child : Person | child.gender = Gender::MALE) ,[object Object]
Collection::collect iteration ,[object Object],self.children ,[object Object],self.children->collect(children) self.children->collect(child | child.children) self.children->collect(child : Person | child.children) ,[object Object],[object Object]
OCL Navigation Operators anObject.  ...  object navigation aCollection->  ...  collection navigation Shorthands aCollection.  ...  implicit collect anObject->  ...  implicit as set Object Collection . Navigation ? -> ? Navigation
Implicit Collect Query parents.parents = parents->collect(parents) 3 symbols, compared to 4 lines of Java 4 grandparents, but not all different!
Cleaned up query parents.parents->asSet()->sortedBy(name) ->asSet()  converts to Set(Person), removes duplicates ->sortedBy(name)  alphabeticizes
Implicit As Set Conversion self->notEmpty() ,[object Object]
If  self  is a defined object ,[object Object],[object Object],[object Object],[object Object],[object Object],Object Collection . Navigation Implicit collect() -> Implicit as set Navigation
Collection::closure iteration ,[object Object],self->closure(children) ,[object Object],[ closure in MDT/OCL 1.2, in OMG OCL 2.3 ]
OCL as Implementation any(x)  iteration selects an arbitrary element for which x is true.
Derived Properties For Hera invariant   MixedGenderParents:  father . gender  <>  mother . gender ; fails because father is  null  and mother is  null
Collection exercises
Other OCL Capabilities No time to mention ,[object Object]
Tuples
Association Classes/Qualifiers
@pre values
Messages
States
OCL in Code - Java API ,[object Object]
evaluating OCL
Facade to hide internals
'Internal' API for derived language parse/evaluate  ,[object Object],[object Object],[object Object],[object Object]
The Re-Evaluation Problem ,[object Object]
System comprising a set of model elements
A model element changes ....
Which of the OCL expressions may have changed its value on which context elements?
Naïve approach ,[object Object]
takes O(|expressions| * |modelElements|)
The Impact Analyzer ,[object Object],[object Object]
re-evaluate ,[object Object]
only expression for which model element is changed Go to Efficient, Scalable Notification Handling for EMF (2 hours ago).
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) Total Re-Evaluation Time in Seconds Number of Model Elements
Benchmark Context Reduction (Worst Case) Naive Event-Filtered (*2.4 Speed-Up) Event-Filtered and Context-Reduced (*27 Speed-Up vs. Naive, *11 vs. Event-Filtered-Only) Total Re-Evaluation Time in Seconds Number of Model Elements (apply changes to very central elements, referenced by all other model packages)
State Machine Example ,[object Object]
OCLinEcore to avoid OCL getting lost ,[object Object]
Use QVTo and OCL to flatten state machine
Xtext with independent OCL Main Eclipse ,[object Object],[object Object]
Tailor Editor
Generate States Editor ,[object Object],Run-time Eclipse ,[object Object],[object Object]
Start Run-time
Edit  simple.states ,[object Object]
Start Run-time
Edit  simple.states ,[object Object]
Simple State Machine DSL module   &quot;simple.states&quot; statemachine  Machine { events  START STOP; state  Start { STOP  => Stop } initial   state  Stop  { START => Start }  }
The Xtext States Grammar http://www.eclipse.org/modeling/mdt/ocl/docs/publications/EclipseCon2011Tutorial /org.eclipse.ocl.tutorial.eclipsecon2011.states/src/org/eclipse/ocl/tutorial/eclipsecon2011/States.xtext grammar  org.eclipse.ocl.tutorial.eclipsecon2011.States with  org.eclipse.xtext.common.Terminals generate  states  &quot;http://ocl.eclipse.org/tutorial/eclipsecon2011/States&quot; Module:  'module'  name=STRING (machines+=Statemachine)*; Statemachine:  (initial?= 'initial' )?  'statemachine'  name=ID ( 'value'  value=INT)?  '{' 'events'  (events+=Event)*  ';' (states+=State)*  '}' ; Event:  name=ID; State:  SimpleState | CompoundState; SimpleState:  (initial?= 'initial' )?  'state'  name=ID ( 'value'  value=INT)? '{'  (transitions+=Transition)*  '}' ; CompoundState:  'compound'  (initial?= 'initial' )?  'state'  name=ID 'machine'  machine=[ Statemachine ] '{'  (transitions+=Transition)*  '}' ; Transition:  event=[ Event ]  '=>'  state=[ State ];
Validation Diagnose inappropriate source text ,[object Object]
inappropriate names:  ,[object Object],[object Object],[object Object]
Embedded OCLinEcore Validation
External Complete OCL Validation ,[object Object],org.eclipse.ocl.examples.xtext.completeocl ,[object Object]
StatesJavaValidator.java ,[object Object],import  org.eclipse.emf.common.util.URI; import  org.eclipse.ocl.examples.xtext.completeocl.validation.CompleteOCLEObjectValidator; import  org.eclipse.ocl.tutorial.eclipsecon2011.states.StatesPackage; import  org.eclipse.xtext.validation.EValidatorRegistrar; public   class  StatesJavaValidator  extends  AbstractStatesJavaValidator { @Override public   void  register(EValidatorRegistrar registrar) { super .register(registrar); StatesPackage ePackage = StatesPackage. eINSTANCE ; URI oclURI = URI. createPlatformResourceURI ( &quot;/org.eclipse.ocl.tutorial.eclipsecon2011.states.ocl/model/States.ocl&quot; ,  true ); registrar.register(ePackage, new  CompleteOCLEObjectValidator(ePackage, oclURI)); } }
Complete OCL Validation 1 /org.eclipse.ocl.tutorial.eclipsecon2011.states.ocl/model/States.ocl import   'http://ocl.eclipse.org/tutorial/eclipsecon2011/States' package   states context   Statemachine inv  HasInitialState( 'No initial state' ): states -> exists ( s  :  State  |  s . initial ) endpackage Evaluates:  states -> exists ( s  :  State  |  s . initial ) true => silent, invariant is satisfied false => invariant is not satisfied evaluates  'No initial state'  to determine warning diagnostic null => invariant is not satisfied evaluates  'No initial state'  to determine error diagnostic invalid => exception, evaluation failure

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Solid Principles
Solid PrinciplesSolid Principles
Solid Principles
 
Ch 3 event driven programming
Ch 3 event driven programmingCh 3 event driven programming
Ch 3 event driven programming
 
Polimorfismo y herencia
Polimorfismo y herenciaPolimorfismo y herencia
Polimorfismo y herencia
 
Object oriented programming interview questions
Object oriented programming interview questionsObject oriented programming interview questions
Object oriented programming interview questions
 
Prototype pattern
Prototype patternPrototype pattern
Prototype pattern
 
OOPs Concepts - Android Programming
OOPs Concepts - Android ProgrammingOOPs Concepts - Android Programming
OOPs Concepts - Android Programming
 
4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT
 
ES6 presentation
ES6 presentationES6 presentation
ES6 presentation
 
GraphQL
GraphQLGraphQL
GraphQL
 
Design Principles
Design PrinciplesDesign Principles
Design Principles
 
C#ppt
C#pptC#ppt
C#ppt
 
Control structures IN SWIFT
Control structures IN SWIFTControl structures IN SWIFT
Control structures IN SWIFT
 
INTERACCIÓN ENTRE CLASES, GENERALIZACIÓN
INTERACCIÓN ENTRE CLASES, GENERALIZACIÓNINTERACCIÓN ENTRE CLASES, GENERALIZACIÓN
INTERACCIÓN ENTRE CLASES, GENERALIZACIÓN
 
Programacion orientada a objetos 2
Programacion orientada a objetos 2Programacion orientada a objetos 2
Programacion orientada a objetos 2
 
Core java
Core java Core java
Core java
 
Greenfoot 3
Greenfoot 3Greenfoot 3
Greenfoot 3
 
Builder Design Pattern (Generic Construction -Different Representation)
Builder Design Pattern (Generic Construction -Different Representation)Builder Design Pattern (Generic Construction -Different Representation)
Builder Design Pattern (Generic Construction -Different Representation)
 
Builder design pattern
Builder design patternBuilder design pattern
Builder design pattern
 
Patrones estructurales
Patrones estructuralesPatrones estructurales
Patrones estructurales
 
SOLID Design Principles applied in Java
SOLID Design Principles applied in JavaSOLID Design Principles applied in Java
SOLID Design Principles applied in Java
 

Destacado

BEEM magnetic microscopy - Data Storage
BEEM magnetic microscopy - Data StorageBEEM magnetic microscopy - Data Storage
BEEM magnetic microscopy - Data Storageniazi2012
 
Enriching Your Models with OCL
Enriching Your Models with OCLEnriching Your Models with OCL
Enriching Your Models with OCLEdward Willink
 
OCL'16 slides: Models from Code or Code as a Model?
OCL'16 slides: Models from Code or Code as a Model?OCL'16 slides: Models from Code or Code as a Model?
OCL'16 slides: Models from Code or Code as a Model?Antonio García-Domínguez
 
Progettazione Collaborativa di Scenari di Apprendimento/Insegnamento
Progettazione Collaborativa  di Scenari di Apprendimento/InsegnamentoProgettazione Collaborativa  di Scenari di Apprendimento/Insegnamento
Progettazione Collaborativa di Scenari di Apprendimento/InsegnamentoMETIS-project
 
Education 2.0: Leveraging Collaborative Tools for Teaching
Education 2.0: Leveraging Collaborative Tools for TeachingEducation 2.0: Leveraging Collaborative Tools for Teaching
Education 2.0: Leveraging Collaborative Tools for TeachingJean-Claude Bradley
 
Collaborative Design of Teaching Scenarios
Collaborative Design of Teaching ScenariosCollaborative Design of Teaching Scenarios
Collaborative Design of Teaching ScenariosMETIS-project
 
Automatic Support for the Analysis of Online Collaborative Learning Chat Conv...
Automatic Support for the Analysis of Online Collaborative Learning Chat Conv...Automatic Support for the Analysis of Online Collaborative Learning Chat Conv...
Automatic Support for the Analysis of Online Collaborative Learning Chat Conv...Stefan Trausan-Matu
 
Online collaborative learning
Online collaborative learningOnline collaborative learning
Online collaborative learningCal McNiven
 
Online Collaborative Learning in ELT
Online Collaborative Learning in ELTOnline Collaborative Learning in ELT
Online Collaborative Learning in ELTClaudio Franco
 
Peer assessment in online collaborative learning
Peer assessment in online collaborative learningPeer assessment in online collaborative learning
Peer assessment in online collaborative learningAleksandra Lazareva
 
From Research to Practice: The Instructional Design of Online Collaborative L...
From Research to Practice: The Instructional Design of Online Collaborative L...From Research to Practice: The Instructional Design of Online Collaborative L...
From Research to Practice: The Instructional Design of Online Collaborative L...laurieposey
 
Introduction to Google Apps For Education
Introduction to Google Apps For Education Introduction to Google Apps For Education
Introduction to Google Apps For Education Steven Hall
 
You need to extend your models? EMF Facet vs. EMF Profiles
You need to extend your models? EMF Facet vs. EMF ProfilesYou need to extend your models? EMF Facet vs. EMF Profiles
You need to extend your models? EMF Facet vs. EMF ProfilesPhilip Langer
 
Collaborative and cooperative learning
Collaborative and cooperative learningCollaborative and cooperative learning
Collaborative and cooperative learningMaryan Lopez
 
OCL Specification Status
OCL Specification StatusOCL Specification Status
OCL Specification StatusEdward Willink
 

Destacado (20)

OCL tutorial
OCL tutorial OCL tutorial
OCL tutorial
 
Ocl exercises 1
Ocl exercises 1Ocl exercises 1
Ocl exercises 1
 
Eclipse OCL Summary
Eclipse OCL SummaryEclipse OCL Summary
Eclipse OCL Summary
 
Cours ocl
Cours oclCours ocl
Cours ocl
 
BEEM magnetic microscopy - Data Storage
BEEM magnetic microscopy - Data StorageBEEM magnetic microscopy - Data Storage
BEEM magnetic microscopy - Data Storage
 
Enriching Your Models with OCL
Enriching Your Models with OCLEnriching Your Models with OCL
Enriching Your Models with OCL
 
OCL'16 slides: Models from Code or Code as a Model?
OCL'16 slides: Models from Code or Code as a Model?OCL'16 slides: Models from Code or Code as a Model?
OCL'16 slides: Models from Code or Code as a Model?
 
Progettazione Collaborativa di Scenari di Apprendimento/Insegnamento
Progettazione Collaborativa  di Scenari di Apprendimento/InsegnamentoProgettazione Collaborativa  di Scenari di Apprendimento/Insegnamento
Progettazione Collaborativa di Scenari di Apprendimento/Insegnamento
 
Education 2.0: Leveraging Collaborative Tools for Teaching
Education 2.0: Leveraging Collaborative Tools for TeachingEducation 2.0: Leveraging Collaborative Tools for Teaching
Education 2.0: Leveraging Collaborative Tools for Teaching
 
Collaborative Design of Teaching Scenarios
Collaborative Design of Teaching ScenariosCollaborative Design of Teaching Scenarios
Collaborative Design of Teaching Scenarios
 
Automatic Support for the Analysis of Online Collaborative Learning Chat Conv...
Automatic Support for the Analysis of Online Collaborative Learning Chat Conv...Automatic Support for the Analysis of Online Collaborative Learning Chat Conv...
Automatic Support for the Analysis of Online Collaborative Learning Chat Conv...
 
Online collaborative learning
Online collaborative learningOnline collaborative learning
Online collaborative learning
 
Online Collaborative Learning in ELT
Online Collaborative Learning in ELTOnline Collaborative Learning in ELT
Online Collaborative Learning in ELT
 
Peer assessment in online collaborative learning
Peer assessment in online collaborative learningPeer assessment in online collaborative learning
Peer assessment in online collaborative learning
 
From Research to Practice: The Instructional Design of Online Collaborative L...
From Research to Practice: The Instructional Design of Online Collaborative L...From Research to Practice: The Instructional Design of Online Collaborative L...
From Research to Practice: The Instructional Design of Online Collaborative L...
 
Introduction to Google Apps For Education
Introduction to Google Apps For Education Introduction to Google Apps For Education
Introduction to Google Apps For Education
 
You need to extend your models? EMF Facet vs. EMF Profiles
You need to extend your models? EMF Facet vs. EMF ProfilesYou need to extend your models? EMF Facet vs. EMF Profiles
You need to extend your models? EMF Facet vs. EMF Profiles
 
Collaborative and cooperative learning
Collaborative and cooperative learningCollaborative and cooperative learning
Collaborative and cooperative learning
 
Java vs .Net
Java vs .NetJava vs .Net
Java vs .Net
 
OCL Specification Status
OCL Specification StatusOCL Specification Status
OCL Specification Status
 

Similar a Enrich Your Models With OCL

Xml Java
Xml JavaXml Java
Xml Javacbee48
 
A Survey of Concurrency Constructs
A Survey of Concurrency ConstructsA Survey of Concurrency Constructs
A Survey of Concurrency ConstructsTed Leung
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to javaciklum_ods
 
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go WrongJDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go WrongPROIDEA
 
Introduction to clojure
Introduction to clojureIntroduction to clojure
Introduction to clojureAbbas Raza
 
New and improved: Coming changes to the unittest module
 	 New and improved: Coming changes to the unittest module 	 New and improved: Coming changes to the unittest module
New and improved: Coming changes to the unittest modulePyCon Italia
 
Linq 1224887336792847 9
Linq 1224887336792847 9Linq 1224887336792847 9
Linq 1224887336792847 9google
 
Java history, versions, types of errors and exception, quiz
Java history, versions, types of errors and exception, quiz Java history, versions, types of errors and exception, quiz
Java history, versions, types of errors and exception, quiz SAurabh PRajapati
 
Fast, Faster and Super-Fast Queries
Fast, Faster and Super-Fast QueriesFast, Faster and Super-Fast Queries
Fast, Faster and Super-Fast QueriesEdward Willink
 
Eclipse Modeling Framework
Eclipse Modeling FrameworkEclipse Modeling Framework
Eclipse Modeling FrameworkAjay K
 
Implementing the Genetic Algorithm in XSLT: PoC
Implementing the Genetic Algorithm in XSLT: PoCImplementing the Genetic Algorithm in XSLT: PoC
Implementing the Genetic Algorithm in XSLT: PoCjimfuller2009
 
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of TonguesChoose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of TonguesCHOOSE
 
Testing And Drupal
Testing And DrupalTesting And Drupal
Testing And DrupalPeter Arato
 

Similar a Enrich Your Models With OCL (20)

Erlang, an overview
Erlang, an overviewErlang, an overview
Erlang, an overview
 
Ocl
OclOcl
Ocl
 
55j7
55j755j7
55j7
 
Xml Java
Xml JavaXml Java
Xml Java
 
A Survey of Concurrency Constructs
A Survey of Concurrency ConstructsA Survey of Concurrency Constructs
A Survey of Concurrency Constructs
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to java
 
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go WrongJDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
 
Introduction to clojure
Introduction to clojureIntroduction to clojure
Introduction to clojure
 
Spring
SpringSpring
Spring
 
New and improved: Coming changes to the unittest module
 	 New and improved: Coming changes to the unittest module 	 New and improved: Coming changes to the unittest module
New and improved: Coming changes to the unittest module
 
biopython, doctest and makefiles
biopython, doctest and makefilesbiopython, doctest and makefiles
biopython, doctest and makefiles
 
Linq 1224887336792847 9
Linq 1224887336792847 9Linq 1224887336792847 9
Linq 1224887336792847 9
 
Java history, versions, types of errors and exception, quiz
Java history, versions, types of errors and exception, quiz Java history, versions, types of errors and exception, quiz
Java history, versions, types of errors and exception, quiz
 
Fast, Faster and Super-Fast Queries
Fast, Faster and Super-Fast QueriesFast, Faster and Super-Fast Queries
Fast, Faster and Super-Fast Queries
 
ECMAScript 2015
ECMAScript 2015ECMAScript 2015
ECMAScript 2015
 
Eclipse Modeling Framework
Eclipse Modeling FrameworkEclipse Modeling Framework
Eclipse Modeling Framework
 
Implementing the Genetic Algorithm in XSLT: PoC
Implementing the Genetic Algorithm in XSLT: PoCImplementing the Genetic Algorithm in XSLT: PoC
Implementing the Genetic Algorithm in XSLT: PoC
 
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of TonguesChoose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
 
Aligning OCL and UML
Aligning OCL and UMLAligning OCL and UML
Aligning OCL and UML
 
Testing And Drupal
Testing And DrupalTesting And Drupal
Testing And Drupal
 

Más de Edward Willink

OCL Visualization A Reality Check
OCL Visualization A Reality CheckOCL Visualization A Reality Check
OCL Visualization A Reality CheckEdward Willink
 
OCL 2019 Keynote Retrospective and Prospective
OCL 2019 Keynote Retrospective and ProspectiveOCL 2019 Keynote Retrospective and Prospective
OCL 2019 Keynote Retrospective and ProspectiveEdward Willink
 
A text model - Use your favourite M2M for M2T
A text model - Use your favourite M2M for M2TA text model - Use your favourite M2M for M2T
A text model - Use your favourite M2M for M2TEdward Willink
 
Commutative Short Circuit Operators
Commutative Short Circuit OperatorsCommutative Short Circuit Operators
Commutative Short Circuit OperatorsEdward Willink
 
Deterministic Lazy Mutable OCL Collections
Deterministic Lazy Mutable OCL CollectionsDeterministic Lazy Mutable OCL Collections
Deterministic Lazy Mutable OCL CollectionsEdward Willink
 
The Micromapping Model of Computation
The Micromapping Model of ComputationThe Micromapping Model of Computation
The Micromapping Model of ComputationEdward Willink
 
Optimized declarative transformation First Eclipse QVTc results
Optimized declarative transformation First Eclipse QVTc resultsOptimized declarative transformation First Eclipse QVTc results
Optimized declarative transformation First Eclipse QVTc resultsEdward Willink
 
Local Optimizations in Eclipse QVTc and QVTr using the Micro-Mapping Model of...
Local Optimizations in Eclipse QVTc and QVTr using the Micro-Mapping Model of...Local Optimizations in Eclipse QVTc and QVTr using the Micro-Mapping Model of...
Local Optimizations in Eclipse QVTc and QVTr using the Micro-Mapping Model of...Edward Willink
 
The Importance of Opposites
The Importance of OppositesThe Importance of Opposites
The Importance of OppositesEdward Willink
 
At Last an OCL Debugger
At Last an OCL DebuggerAt Last an OCL Debugger
At Last an OCL DebuggerEdward Willink
 
QVT Traceability: What does it really mean?
QVT Traceability: What does it really mean?QVT Traceability: What does it really mean?
QVT Traceability: What does it really mean?Edward 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
 
OCL Integration and Code Generation
OCL Integration and Code GenerationOCL Integration and Code Generation
OCL Integration and Code GenerationEdward Willink
 
Yet Another Three QVT Languages
Yet Another Three QVT LanguagesYet Another Three QVT Languages
Yet Another Three QVT LanguagesEdward Willink
 

Más de Edward Willink (20)

An OCL Map Type
An OCL Map TypeAn OCL Map Type
An OCL Map Type
 
OCL Visualization A Reality Check
OCL Visualization A Reality CheckOCL Visualization A Reality Check
OCL Visualization A Reality Check
 
OCL 2019 Keynote Retrospective and Prospective
OCL 2019 Keynote Retrospective and ProspectiveOCL 2019 Keynote Retrospective and Prospective
OCL 2019 Keynote Retrospective and Prospective
 
A text model - Use your favourite M2M for M2T
A text model - Use your favourite M2M for M2TA text model - Use your favourite M2M for M2T
A text model - Use your favourite M2M for M2T
 
Shadow Objects
Shadow ObjectsShadow Objects
Shadow Objects
 
Commutative Short Circuit Operators
Commutative Short Circuit OperatorsCommutative Short Circuit Operators
Commutative Short Circuit Operators
 
Deterministic Lazy Mutable OCL Collections
Deterministic Lazy Mutable OCL CollectionsDeterministic Lazy Mutable OCL Collections
Deterministic Lazy Mutable OCL Collections
 
The Micromapping Model of Computation
The Micromapping Model of ComputationThe Micromapping Model of Computation
The Micromapping Model of Computation
 
Optimized declarative transformation First Eclipse QVTc results
Optimized declarative transformation First Eclipse QVTc resultsOptimized declarative transformation First Eclipse QVTc results
Optimized declarative transformation First Eclipse QVTc results
 
Local Optimizations in Eclipse QVTc and QVTr using the Micro-Mapping Model of...
Local Optimizations in Eclipse QVTc and QVTr using the Micro-Mapping Model of...Local Optimizations in Eclipse QVTc and QVTr using the Micro-Mapping Model of...
Local Optimizations in Eclipse QVTc and QVTr using the Micro-Mapping Model of...
 
The Importance of Opposites
The Importance of OppositesThe Importance of Opposites
The Importance of Opposites
 
The OCLforUML Profile
The OCLforUML ProfileThe OCLforUML Profile
The OCLforUML Profile
 
At Last an OCL Debugger
At Last an OCL DebuggerAt Last an OCL Debugger
At Last an OCL Debugger
 
QVT Traceability: What does it really mean?
QVT Traceability: What does it really mean?QVT Traceability: What does it really mean?
QVT Traceability: What does it really mean?
 
Safe navigation in OCL
Safe navigation in OCLSafe navigation in OCL
Safe navigation in OCL
 
OCL 2.4. (... 2.5)
OCL 2.4. (... 2.5)OCL 2.4. (... 2.5)
OCL 2.4. (... 2.5)
 
Embedded OCL Integration and Debugging
Embedded OCL Integration and DebuggingEmbedded OCL Integration and Debugging
Embedded OCL Integration and Debugging
 
OCL 2.5 plans
OCL 2.5 plansOCL 2.5 plans
OCL 2.5 plans
 
OCL Integration and Code Generation
OCL Integration and Code GenerationOCL Integration and Code Generation
OCL Integration and Code Generation
 
Yet Another Three QVT Languages
Yet Another Three QVT LanguagesYet Another Three QVT Languages
Yet Another Three QVT Languages
 

Último

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
 
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
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 

Último (20)

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
 
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
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

Enrich Your Models With OCL

  • 1. Enrich Your Models with OCL Edward Willink, Thales MDT/OCL Project Lead Axel Uhl, SAP 21st March 2011
  • 2. Part 1: OCL in isolation Installation Instructions OCL Basic Principles exercises OCL Collections and Iterators exercises OCL tools and usage exercises OCL in Java - analyzable language
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 12.
  • 14.
  • 15.
  • 16.
  • 17.
  • 20.
  • 21.
  • 22.
  • 23.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33. M2M: OMG QVT, Eclipse QVTo, ATL, Epsilon
  • 34. M2T: OMG MOFM2T, Eclipse Acceleo
  • 35.
  • 36.
  • 37. Multiplicity Example Family Tree Meta-Model Ecore Diagram (similar to UML Class Diagram)
  • 38.
  • 39.
  • 40. 1 MALE, 1 FEMALE parent
  • 41. Self is not an ancestor of self
  • 42. Example Family Tree Model Simple GMF Diagram Editor Runtime Workspace: ESEExampleTree/model/default.people_diagram
  • 43. Simple Query Evaluation Window->Show View->Other... Console Console: New: Interactive Xtext OCL Select Zeus as the Model Context (in any model editor) Type children then carriage return
  • 44.
  • 45. side effect free, no model changes, atomic execution
  • 46. strongly typed, using UML generalization
  • 47. Primitive Types and Literals Java (implementation) OCL (specification) boolean,Boolean,true,false Boolean,true,false short,int,long,Integer,BigInteger Integer , UnlimitedNatural float, double, BigDecimal Real Character, String, 'c', &quot; line &quot; String, 'c', ' line ' Object,this,null OclAny, self ,null Exception invalid Integer value value : Integer Java: practical implementation language OCL: simpler, idealistic, specification language
  • 48. Mathematical Operators Java (implementation) OCL (specification) +, -, *, / +, -, *, / !, &&, ||, ^ not, and, or, xor, implies <, >, <=, >= <, >, <=, >= ==, != = , <> Math.max(4,5) 4.max(5) if (a) b else c; if a then b else c endif Integer value = 5; doSomething(value); let value : Integer = 5 in doSomething(value)
  • 49. More Complex Query Selecting Hera defines the implicit context variable self : Person = Hera
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55. Setting Delegate for EStructuralFeature initial value
  • 57. The OCLinEcore Editor OCLinEcore editor maintains EAnnotations automatically OCLinEcore editor provides OCL syntax checking OCLinEcore editor will provide OCL semantic checking
  • 58.
  • 59.
  • 61. Example Validation Failure Open ESEExampleTree/model/People1.xmi in Main Eclipse, with Sample Reflective Ecore Editor Select Universe, Right button menu, Validate
  • 62.
  • 63.
  • 65.
  • 66.
  • 67. getChildren().get(2) getChildren().add(newChild) OCL needs more than just UML multiplicities
  • 68.
  • 69.
  • 70.
  • 71.
  • 72. OCL Navigation Operators anObject. ... object navigation aCollection-> ... collection navigation Shorthands aCollection. ... implicit collect anObject-> ... implicit as set Object Collection . Navigation ? -> ? Navigation
  • 73. Implicit Collect Query parents.parents = parents->collect(parents) 3 symbols, compared to 4 lines of Java 4 grandparents, but not all different!
  • 74. Cleaned up query parents.parents->asSet()->sortedBy(name) ->asSet() converts to Set(Person), removes duplicates ->sortedBy(name) alphabeticizes
  • 75.
  • 76.
  • 77.
  • 78. OCL as Implementation any(x) iteration selects an arbitrary element for which x is true.
  • 79. Derived Properties For Hera invariant MixedGenderParents: father . gender <> mother . gender ; fails because father is null and mother is null
  • 81.
  • 87.
  • 89. Facade to hide internals
  • 90.
  • 91.
  • 92. System comprising a set of model elements
  • 93. A model element changes ....
  • 94. Which of the OCL expressions may have changed its value on which context elements?
  • 95.
  • 96. takes O(|expressions| * |modelElements|)
  • 97.
  • 98.
  • 99. only expression for which model element is changed Go to Efficient, Scalable Notification Handling for EMF (2 hours ago).
  • 100. 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) Total Re-Evaluation Time in Seconds Number of Model Elements
  • 101. Benchmark Context Reduction (Worst Case) Naive Event-Filtered (*2.4 Speed-Up) Event-Filtered and Context-Reduced (*27 Speed-Up vs. Naive, *11 vs. Event-Filtered-Only) Total Re-Evaluation Time in Seconds Number of Model Elements (apply changes to very central elements, referenced by all other model packages)
  • 102.
  • 103.
  • 104. Use QVTo and OCL to flatten state machine
  • 105.
  • 107.
  • 109.
  • 111.
  • 112. Simple State Machine DSL module &quot;simple.states&quot; statemachine Machine { events START STOP; state Start { STOP => Stop } initial state Stop { START => Start } }
  • 113. The Xtext States Grammar http://www.eclipse.org/modeling/mdt/ocl/docs/publications/EclipseCon2011Tutorial /org.eclipse.ocl.tutorial.eclipsecon2011.states/src/org/eclipse/ocl/tutorial/eclipsecon2011/States.xtext grammar org.eclipse.ocl.tutorial.eclipsecon2011.States with org.eclipse.xtext.common.Terminals generate states &quot;http://ocl.eclipse.org/tutorial/eclipsecon2011/States&quot; Module: 'module' name=STRING (machines+=Statemachine)*; Statemachine: (initial?= 'initial' )? 'statemachine' name=ID ( 'value' value=INT)? '{' 'events' (events+=Event)* ';' (states+=State)* '}' ; Event: name=ID; State: SimpleState | CompoundState; SimpleState: (initial?= 'initial' )? 'state' name=ID ( 'value' value=INT)? '{' (transitions+=Transition)* '}' ; CompoundState: 'compound' (initial?= 'initial' )? 'state' name=ID 'machine' machine=[ Statemachine ] '{' (transitions+=Transition)* '}' ; Transition: event=[ Event ] '=>' state=[ State ];
  • 114.
  • 115.
  • 117.
  • 118.
  • 119. Complete OCL Validation 1 /org.eclipse.ocl.tutorial.eclipsecon2011.states.ocl/model/States.ocl import 'http://ocl.eclipse.org/tutorial/eclipsecon2011/States' package states context Statemachine inv HasInitialState( 'No initial state' ): states -> exists ( s : State | s . initial ) endpackage Evaluates: states -> exists ( s : State | s . initial ) true => silent, invariant is satisfied false => invariant is not satisfied evaluates 'No initial state' to determine warning diagnostic null => invariant is not satisfied evaluates 'No initial state' to determine error diagnostic invalid => exception, evaluation failure
  • 121. Complete OCL Validation 2 context Statemachine def : asError(verdict : Boolean ) : Boolean = if verdict then true else null endif inv HasInitialState( 'No initial state' ): asError ( states -> exists ( s : State | s . initial )) context SimpleState inv NameLength( 'apos;' + name + 'apos; has ' + name . size (). toString () + ' characters when at least 4 wanted' ): name . size () >= 4 inv NameIsLeadingUpperCase( 'apos;' + name + 'apos; must be Leading Uppercase' ): let firstLetter : String = name . substring ( 1 , 1 ) in firstLetter . toUpperCase () = firstLetter
  • 122. Complete OCL Validation 3 context SimpleState def : statemachine : Statemachine = oclContainer ()-> oclAsType ( Statemachine ) inv UniqueInitialState( 'There is more than one initial state' ): initial implies statemachine . states -> select ( initial )-> size () = 1 inv EveryEventIsHandled( let allEvents : Set ( Event ) = statemachine . events -> asSet (), myEvents : Set ( Event ) = self . transitions . event -> asSet () in ( allEvents - myEvents )-> iterate ( e : Event ; s : String = 'The following events are not handled:' | s + ' ' + e . name )): let allEvents : Set ( Event ) = statemachine . events -> asSet (), myEvents : Set ( Event ) = self . transitions . event -> asSet () in ( allEvents - myEvents )-> isEmpty ()
  • 124.
  • 125.
  • 126.
  • 127.
  • 129. Model URI: platform:/resource/org.eclipse.ocl.tutorial.eclipsecon2011.states/ src-gen/org/eclipse/ocl/tutorial/eclipsecon2011/States.ecore
  • 130.
  • 131.
  • 132. check that NameIsUppercase is working
  • 133.
  • 134.
  • 135. tip 2: the closure of all transitions from all initial states includes the state in question
  • 136.
  • 137.
  • 138.
  • 139.
  • 140.
  • 142.
  • 143.
  • 145.
  • 147.
  • 148.
  • 149.
  • 150.
  • 152. change all ... States.ecore refs to OCLStates.ecore
  • 153. set genmodel Operation Reflection to true
  • 154.
  • 155.
  • 156.
  • 157. ( states ) is over protective pretty-printing
  • 158. [?] is UML oriented [1] not [?] is the default
  • 159. { ordered } is UML oriented { ! ordered unique } is the default
  • 160. Embedded Constraints 2 invariant UniqueInitialState( 'There is more than one initial state' ): initial implies ((( statemachine ). states )-> select ( initial ))-> size () = 1 ; invariant NameIsLeadingUpperCase( 'apos;' + name + 'apos; must be Leading Uppercase' ): let firstLetter : String = ( name ). substring ( 1 , 1 ) in firstLetter . toUpperCase () = firstLetter ; invariant NameLength( 'apos;' + name + 'apos; has ' + (( name ). size ()). toString () + ' characters when at least 4 wanted' ): ( name ). size () >= 4 ; invariant EveryEventIsHandled( let allEvents : Set ( Event ) = (( statemachine ). events )-> asSet () in let myEvents : Set ( Event ) = (( self . transitions )-> collect ( event ))-> asSet () in ( allEvents - myEvents )-> iterate ( e : Event ; s : String = 'The following events are not handled:' | s + ' ' + e . name )): let allEvents : Set ( Event ) = (( statemachine ). events )-> asSet () in let myEvents : Set ( Event ) = (( self . transitions )-> collect ( event ))-> asSet () in ( allEvents - myEvents )-> isEmpty (); property statemachine : Statemachine [?] { derived } { derivation : ( oclContainer ()). oclAsType ( Statemachine ); }
  • 161.
  • 162. Use an extended Validator API for
  • 163.
  • 164.
  • 165.
  • 166.
  • 167. Add a new constraint to OCLStates.ecore
  • 168. Regenerate Java with OCLStates.genmodel
  • 169.
  • 170.
  • 173. Run Generate Simple States
  • 174. Inspect *.java generate.mtl
  • 175.
  • 176.
  • 177. one class for the State Machine
  • 178. one class for each State
  • 179. one method for each Event
  • 180. States to Java Classes module &quot;simple.states&quot; statemachine Machine { events START STOP; state Start { START => Start } initial state Stop { STOP => Stop } } package simple.states; public class Stop implements Machine.State { private final Machine sm ; public Stop(Machine sm) { this . sm = sm; } public void doSTOP() { sm .setState(STATES. STATE_Stop ); } } package simple.states; public class Machine { public interface State { public void doSTART(); public void doSTOP(); enum STATES { STATE_Start , STATE_Stop } }
  • 181.
  • 182.
  • 184.
  • 185.
  • 186.
  • 187.
  • 188.
  • 189. OCL: e.name + '.java' e.states
  • 190.
  • 191.
  • 192. package simple.states; public class Machine { public interface State { public void doSTART(); public void doSTOP(); enum STATES { STATE_Start , STATE_Stop } } Acceleo Text Template 2 [template public generateStatemachineClass(m : Module, e : Statemachine)] package [ m.getPackageName() /] ; public class [ e.getStateMachineClassName() /] { public interface State { [for ( v : Event | e.events) ] public void [ v.getEventMethodName() /] (); [/for] enum STATES { [for ( s : State | e.states) separator ( ',' ) after ( '' ) ] [ s.getStateEnumName() /] [/for] } } ... public [ e.getStateMachineClassName() /] () { setState(State.STATES. [ e.getInitialState().getStateEnumName() /] ); } public Machine() { setState(State.STATES. STATE_Stop ); }
  • 193.
  • 194. protects downstream from garbage in ...
  • 195.
  • 196. Change the enums from STATE to ENUM prefix
  • 198.
  • 200.
  • 202. Run Flatten States to XMI or Flatten States
  • 203. Inspect flattened.xmi Inspect flattened.states FlattenStates.qvto
  • 204.
  • 205.
  • 206.
  • 207. Statemachine Flattening Example module &quot;compound.states&quot; statemachine Outer { events START STOP; initial state Start value 4 { START => CompoundA } state Stop value 5 { STOP => CompoundB } compound state CompoundA machine Inner { START => Stop } compound state CompoundB machine Inner { STOP => Stop } } statemachine Inner { events LEFT RIGHT; initial state Left value 1 { LEFT => Right } state Right { RIGHT => Left } } module &quot;flattened.compound.states&quot; statemachine Outer { events STOP RIGHT LEFT START; initial state Start value 4 { START => CompoundA_Left } state Stop value 5 { STOP => CompoundB_Left } state CompoundA_Left value 1 { LEFT => CompoundA_Right START => Stop } state CompoundA_Right { RIGHT => CompoundA_Left START => Stop } state CompoundB_Left value 1 { LEFT => CompoundB_Right STOP => Stop } state CompoundB_Right { RIGHT => CompoundB_Left STOP => Stop } }
  • 208. root mapping mapping HIER :: Module :: model2FLATModel () : FLAT :: Module { name := 'flattened.' + self . name ; var name2state : Dict ( String , HIER :: State ); var allMachines : Set ( HIER :: Statemachine ) = self . machines . allMachines ()-> asSet (); var allStates : Set ( HIER :: State ) = allMachines. states -> asSet (); var allCompoundStates : Set ( HIER :: CompoundState ) = allStates-> select ( oclIsTypeOf ( HIER :: CompoundState )) -> collect ( oclAsType ( HIER :: CompoundState ))-> asSet (); var rootMachines : Set ( HIER :: Statemachine ) = allMachines-> select (m : HIER :: Statemachine | not allCompoundStates-> exists ( machine = m)); machines := rootMachines-> map machine2machine (name2state); }
  • 209.
  • 210.
  • 211.
  • 212.
  • 213. from-compound => all exitTransitions
  • 214. iterate to form concatenated string query HIER :: State :: getStateName (hierarchy : Sequence ( HIER :: CompoundState )) : String { return hierarchy->iterate(c : HIER :: CompoundState ; s : String = self . name | c. name + '_' + s) }
  • 215. conditional hierachical selection query HIER :: State :: initialStateName (hierarchy : Sequence ( HIER :: CompoundState )) : String { var stateName : String = self . getStateName (hierarchy); return if self . oclIsKindOf ( HIER :: CompoundState ) then let compoundState : HIER :: CompoundState = self . oclAsType ( HIER :: CompoundState ) in compoundState. machine . states -> any ( initial ) . initialStateName (hierarchy-> append (compoundState)) else stateName endif }
  • 216. simple navigation/logic mapping HIER :: SimpleState :: simpleState2state ( name2state : Dict ( String , HIER :: State ), hierarchy : Sequence ( HIER :: CompoundState ) ) : FLAT :: SimpleState { var stateName : String = self . getStateName (hierarchy); name := stateName; value := self . value ; initial := hierarchy-> isEmpty () and self . initial ; name2state-> put (stateName, result ); }
  • 217. iterate to create objects mapping HIER :: SimpleState :: simpleState2transitions2 ( name2state : Dict ( String , HIER :: State ), hierarchy : Sequence ( HIER :: CompoundState ), exitTransitions : Dict ( FLAT :: Event , FLAT :: State ) ) : FLAT :: State { init { var stateName : String = self . getStateName (hierarchy); result := name2state-> get (stateName); } transitions := exitTransitions-> keys ()->iterate(v : FLAT :: Event ; acc : Sequence ( HIER :: Transition ) = self . transitions . map transition2transition (name2state, hierarchy) | acc-> append ( object FLAT :: Transition { state := exitTransitions-> get (v); event := v; }) ); }
  • 218.
  • 219.
  • 220.
  • 222.
  • 225.
  • 226.
  • 227.
  • 228. 'var' used to cache partial/temporary states
  • 229.
  • 230.
  • 231.
  • 232.
  • 233.
  • 234.
  • 235.
  • 236. Ecore behavioral extension - OCLinEcore editor
  • 237. dynamic and genmodeled validation
  • 238.
  • 239. Eclipse OCL evolving an extensible GUI
  • 240.