43
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

OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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

Page 2: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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

Page 3: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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)

Page 4: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled 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

Page 5: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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 +∞-∞

Page 6: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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

Page 7: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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

Page 8: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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

Page 9: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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

Page 10: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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

Page 11: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled 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

Page 12: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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

Page 13: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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

Page 14: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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()

Page 15: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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

Page 16: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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

Page 17: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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)

Page 18: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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

Page 19: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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

Page 20: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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

Page 21: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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)

Page 22: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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])

Page 23: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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

Page 24: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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

Page 25: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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>

Page 26: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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)

Page 27: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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?

Page 28: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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

Page 29: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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}

Page 30: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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

Page 31: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

21-March-2012 OCL omissions and contradictions Made available under EPL 1.0

Page 32: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

21-March-2012 OCL omissions and contradictions Made available under EPL 1.0

Page 33: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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

Page 34: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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

Page 35: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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

Page 36: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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

Page 37: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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

Page 38: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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

Page 39: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled 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

Page 40: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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

Page 41: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

21-March-2012 OCL omissions and contradictions Made available under EPL 1.0

Values

Integer ??Type ??OrderedSet ??*Type* ??

Page 42: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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

Page 43: OCL omissions and contradictions - Eclipse€¦ · 21-March-2012 OCL omissions and contradictions Made available under EPL 1.0 OCL 2.5 Goals UML 2.5 aligned consistent Modeled OCL

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

???