OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions...
Transcript of OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions...
Made available under EPL 1.0
OCL omissions and contradictions
Edward Willink
OCL RTF chair,QVT RTF representative
Eclipse OCL Project Lead,Eclipse QVTd Project Lead,
OMG ADTF
21st March 2012
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
Overview
Background/Goals for OCL '2.5'Values - UML alignment
Problems and SolutionsTypes - UML alignment
Problems and Solutions[ Operations - UML alignment
Problems and Solutions ]Summary
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
OCL 2.5 Goals
UML 2.5 alignedconsistent
Modeled OCL 'Standard' Libraryextensible, third party/domain libraries
Small Core Language + Librariesmove Message, State support to library operations
Fully modeled100% auto-generated Frame specification (MOFM2T)auto-generated tooling (prototype in new Eclipse OCL)
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
true = true ?
OCL 2.3: No Boolean overload of OclAny::=(...)OclAny::=(object2 : OclAny) : Boolean True if self is the same object as object2. Infix operator.post: result = (self = object2)
true only equal to trueif both trues are the same objectno requirement for singleton valuesno tool does this
OCL 2.5: Primitive types use value equality
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
1 = 1.0 ?Set{1}->including{1.0}->size()
Set{Set{1}}->including{Set{1.0}}->size()
OCL 2.3: No numeric overload of OclAny::=(...)[Java primitives equal, objects not equal]OCL is a specification language
numbers are points on an infinite number line
OCL 2.5: Numbers use numeric equality
1 2 3 40
1.0 e π
1 +∞-∞
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
UML Primitive Usage
Primitives (Boolean, Integer, Real ...) have nobehaviour, representation, conformance
Representation provided by host ClassBehaviour/Role defined by host Class
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
OCL Primitive Usage
StringValue hosts the String primitiveprovides a representation
OCL Standard Library defines behaviouroperations of StringValue
not String, not a companion class
OCL specification defines conformance
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
OCL normalized/pivot values
Already in OCL 2.0no specified API
NoBooleanValueIntegerValueRealValueOrderedSetValue
Irregular...TypeValue
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
OCL 2.5 Pivot Values
Add missing classesBooleanValue, IntegerValue, RealValue, ...
Regularize namesTypeNameValue
Promote Values as a run-time APImake Value class usage a Compliance Point
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
OCL Object Values in Java
ObjectValue can be polymorphican indirection to a real Object representation
Foundation for a Java binding for OCL
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
OCL re-use in a Technology SpaceOCL can be used in many Technology Spaces
UML, EMOF, XML, RDB, ...'Optimum' re-use
use a TS-specific OCL implementation
Difficult: TS/OCL semantics differences1 = 1.0, Set{1,1.0} = Set{1}
Bespoke, irregular, confusing OCL
PersistedTS
Model
LoadedTS
Model
TS-specificOCL Engine
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
OCL re-use for a Technology Space
Model accesses convert TS to OCL Valuesmay be faster
+ no correction for non-OCL TS semantics- a TS to OCL value conversion
lazy collection value conversions
OCL Values should be a conformance point
PersistedTS
Model
LoadedTS
Model
GenericOCL
Values
GenericOCL Engine
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
OCL Types, Meta-model
How is an OCL type aligned to a UML type?not currently specified
PersistedTS
Model
LoadedTS
Model
GenericOCL
Values
GenericOCL Engine
TSMetaModels
GenericOCL
Types
conformsTo
OCLMetaModel
conformsTo
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
OCL Model Elements
Multiple sources of M2 model elementsUML meta-modelEssential OCL meta-modelComplete OCL meta-model
Multiple sources of M1 model elementsOCL 'Standard' LibraryUser meta-modelsComplete OCL documentsM2 elements by reflection - OclAny::oclType()
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
M2 Integration
Selected UML contributions for UML-alignment[Selected] OCL contributions [for tailored OCL]Vendor contributions support practical toolingMerge gives single uniform package
OCL::Class, OCL::OclExpression etc
MEF
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
Example OCL M2 'Merges'
OCL::Class = UML::Class+UML::Classifier+UML::Typein OCL any type can have operations
Eliminate derived unionssimple efficient relationships as in UML Basic
Full navigabilityall association ends are Class-owned
Eliminate non-'MOF' classesno UseCases, Actions, ...
Re-use UML generalization as OCL conformance
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
Example OCL M1 'Merges'
Load user meta-models/librariesfrom UML/EMOF/... Complete OCL, OCLstdlibnormalized to OCL meta-model representation
Insert OclElement as supertype of all user typesCo-ordinate package clashes by URIUnify duplicate specialisations e.g. Set(String)
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
OCL Operations
What are the operation overloading semantics?OCL: aligned to UMLUML: implementation variation pointtherefore unspecified
Proposal: Java-like invariant overloadingA::y(Z) is overloaded by B::y(Z) if B extends A
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
OclSelf
OclSelf is the statically determinate type of selfSelf-variant overloading
Boolean::=(OclSelf) overloads OclAny::=(OclSelf)enhanced invariant overloading: dispatch on
dynamic most derived common type of source, argumenthandles the common binary caseReal::+(OclSelf) always gets 2 Real argumentsInteger::+(OclSelf) always gets 2 Integersno need for type checks
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
OCL IterationsaCollection->iterate(q : String | acc : String = ''; if acc.size() > 0 then acc + ' ' else acc endif + q.toString())
How is iterate modeled?Iteration is an Operation with extra 'parameter's
iterator(s), q : Stringaccumulator, acc : String = ''body is a lambda-expression if acc ... + q.toString()
Collection types are templatesOperations/Iterations may be templates
type Collection<T> : CollectionType conformsTo OclAny { iteration iterate<Tacc>(i : T; acc : Tacc | body : Lambda T() : Tacc) : Tacc
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
Meta-Model Imports
In Complete OCLimport a URI element
import uml : 'UML.uml#_jEB8EDoXEeCmpu-HRutBsg'import a URI element and its child names
import uml : 'UML.uml#_jEB8EDoXEeCmpu-HRutBsg'.*In Essential OCL
no mechanism to contextualize expressionuse URI as a path name element
oclIsKindOf('UML.uml#Activities'::Action)
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
Unified Collection Types
UML: bounded collection typesString[2..4] {ordered}no nested collection types
OCL: nested collection typesSet(OrderedSet(String))no bounded collection types
Inconsistent primary/secondary declarationsUnified Collection Types
Set(OrderedSet(String)[2..4])
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
ReflectionOCL 2.0 Element::getMetaClass()
MOF facility not merged to UMLOCL 2.2 OclAny::oclType() : Classifier
No Classifier in EMOFClassifier at different meta-level
Does OCL support Reflection?
(OCL 2.0) precondition for Sequence::first()self.oclType().elementType.oclIsKindOf(CollectionType)
Yes
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
Unlimited / Plus infinity
[0..*] multiplicity upper bound can be unlimited* is not an Integernew UnlimitedNatural type (and value)UnlimitedNatural is not a simple subtype of Integer
*.oclAsType(Integer) is invalidrequires run-time test
OCL 2.5: * is plus infinityInteger and Real support +/- infinityall UnlimitedNatural values are Integer values
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
Complete OCL 2.3 Property Definitioncontext MyClassdef: upperCaseName : String = name.toUpper()
No Property
PropertyCallExpression.referredProperty impossible in XMI
<def>
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
New Complete OCL Property Definition New Complete OCL Property Definition
Property defined (can be referenced)
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
New Multiple Models Problem
P::X::y defined by a primary UML modelP::X::z defined by a Complete OCL document
How many P's? How Many X's?What is the value of P::X.ownedAttribute?
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
Meta-Model Problems to solveLibrary Modeling
ReflectionIteration
UML alignmentobsolete/inconsistent classes in usetemplates
EMOF (and Ecore and ...) utilityarbitrary meta-meta-models
Complete OCL realizabilitydefinition of real Property/Operationmultiple models, URIs
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
Multiple Models SolutionSimple Model Usage
How many P's? How Many X's?One
What is the value of P::X.ownedAttribute?Set{P::X::y, P::X::z}
Reflective Model Usage, URI AccessHow many P's? How Many X's?
TwoWhat is the value of P::X.ownedAttribute?
depends on P::X - Set{P::X::y} or Set{P::X::z}
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
Summary- Not-new OCL FacilitiesOverloading / dynamic dispatchReflection : oclType(), Class<T>
was T, used in WFRs
Type-valued Expressions : Class<T>used in oclAsType()
Templates/Genericsused in Collection, Collection::product, Tuples
OclSelfwas T
Lambda Types / Expressionsiteration bodies
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
UML Primitives
UML Primitives have no representationensures implementation freedom
UML Primitives have no behaviourcannot be used
UML Primitives have no conformancecannot be interchanged
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
OCL re-use
How does OCL support UML, EMOF, XML, ... ?Customize OCL for each technology space
bespoke, irregular, confusing OCLMap each technology space to OCL
most of OCL is technology space neutraljust model access to align - values and typespartial mapping gives partial support
e.g.EMOF has no AssociationsEMOF to OCL mapping may reconstruct associationsan EMOF problem, not an OCL problem
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
Overview
OCL and UML and EMOFProblems
Complete OCLProblems and Solutions
ValuesProblems and Solutions
Summary
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
OCL Values in Java
xxxValue provides an indirection
IntegerValue/SetValue provide OCL semanticsexploit Java for implementation not behaviour
IntegerValue may be polymorphicint or long or BigInteger representationIntegerValue-for-int similar to java.lang.Integer
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
LocalSnapShots
LocalSnapShot: all names and their valuesuseful for defining semantics
N snapshots for OclMessage history2 snapshots necessary for @pre, not @pre
inefficient for practical implementations
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
UML (and OCL)
UML
MOF
OCL
Complete MOF Essential MOF (≈ Ecore) Powerful, Flexible, Big Small, Effective, Efficient
Analysis Design Implementation
Complete MOF
Complete OCL Essential OCL
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
Significant Problem Summary
OCL for EMOF lacks essential elementsOpaqueExpression, ConstraintTypes with features
Complete OCL incompleteProperty/Operation definition not useableProperty/Operation definition not persistable
OCL not UML alignedAssociationEnd/PropertyAssociationClass
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
Solution Summary
OCL for EMOF lacks essential elementssupport EMOF only indirectly
Complete OCL incompletecomplete it
OCL not UML aligneddefine OCL with respect to UML
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
Values
Integer ??Type ??OrderedSet ??*Type* ??
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
Evaluate
ZZZ + OCLMeta-Model
OCL PivotMeta-Model
YYY + OCLModel
conforms toOCL Pivot
Models
conforms to
XXXValues, Objects
conforms toOCL Value
Objects
conforms to CompileLoad
Load
Adapt
OCL Library Document
Complete OCLDocument
Compile
XXXValue, Object OCL ValueAdapt
21-March-2012 OCL omissions and contradictions Made available under EPL 1.0
UMLMeta-Model
EMOF / EcoreMeta-Model
UMLModel
EMOF / EcoreModelUML Edit Export
conforms to conforms to
UMLModel
UMLModel
OCL for EMOFModelOCL Edit ExportOCL for UML
Model
OCLMeta-Model
conforms to conforms to
OpaqueExpression
ExpressionInOcl
generalises
UML and OCL integration
ExpressionInOcl
???