OCL 2.5 plans

Embed Size (px)

DESCRIPTION

Plans for OCL 2.5 presented at the OCL 2014 Workshop.

Citation preview

  • 1. OCL 2.5 PlansEdward WillinkWillink Transformations LtdEclipse FoundationMMT Component co-LeadOCL Project LeadQVTd Project LeadQVTo CommitterOMG (Model Driven Solutions)OCL 2.3, 2.4 (2.5) RTF ChairQVT 1.2, 1.3 RTF ChairOCL 2014 @ MODELS 201430th September 2014Made available under EPL 1.0

2. OverviewBackground, OMGUser visible changesCritical omission'include'/'import', URI-qualification'No' changes - reify implied functionalityTemplates, Lambdas, ReflectionEasy changes - syntax sugarelseif, safe-navigation, collection completion, patternsTooling changesHard changes, XMI ... ASModularity / extensibility / semantics / exposition30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 2 3. Simple Black Box view of OCLOCLConcrete SyntaxStandard LibrarySemanticsUsersSpecification exposition imperfectPrecise Concrete Syntax GrammarMore functionality30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 3 4. White Box view of OCLOCLConcrete SyntaxStandard LibrarySemanticsUsersLoaderAbstractSyntaxSaverSpecification totally inadequateMissing / UnimplementableRewrite / DesignModelsXMI30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 4 5. Background to OCL 2.5 RFPOCL 1.x specified as part of UML 1.xspecifies that parts that need formal wordsOCL 2.0 split off from UML 2.0OCL useable in its own rightNo resources available to complete specificationQVT 1.0 specified as an extension of OCLOCL 2.0 draft approved TBDs and allOCL 2.1/2.2, 2.3, 2.4 provides limited improvementsconsistency needsneeds major editorial changesneeds model-driven automation30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 5 6. OMG RevisionRevisionssmall fixes (Revision Task Force)issue, resolution, ballot, update, approvalsignificant textual activity (one page/hour per typo)cannot have a 'replace entire chapter' resolutionSubmissionsRequest for ProposalCompeting submissions ... merge/conflict/ballotfinal revision (Finalization Task Force)can make 100% change; it's a new specification30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 6 7. OCL 2.5 RFPhttp://doc.omg.org/ad/2014-3-5Rewrite the OCL specificationAchieve the long overdue UML (2.5) alignment'No' breakage of OCL as used in UML 2.5OCL in UML 2.5 was checked with modern toolingNecessary changes tomake OCL Abstract Syntax interchangeable in XMIresolve numerous magic/inconsistent areasImprove useability/extensibility30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 7 8. OCL 2.5 TimelineLetter of Intent (LOI) deadline 10 November 2014Initial Submission deadline 10 February 2015Voter registration closes 20 February 2015Initial Submission presentations 25 March 2015Revised Submission deadline 18 May 2015Revised Submission presentations 10 June 2015... Finalization Task Force ...... ? approval late 2016Prototyped in Eclipse OCL (Mars, June 2015)30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 8 9. Critical Omissions - Model ImportComplete OCLdocument complements what?implementation-specific solutionsimport 'mm-package-uri'import alias : 'mm-package-uri'library 'lib-package-uri'Essential OCLtext is the dominant OCL persistenceno import possibleoclIsKindOf('package-uri'::MyType)first namespace qualifier may be a quoted URI30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 9 10. Implied Functionality - Lambdass->forAll(a, b | a + b 0)a+b0 specified in OCL 2.4 as a textual macroa+b0 is a lambda expression in OCL 2.5library modeling needs a lambda typeallow assignment to variableslet f(p : Real, q : Real) = p + q 0in s->forAll(a, b | f(a,b))let f(p : Real, q : Real) :Lambda(p : Real, q : Real) : Boolean = p + q 0in s->forAll(a : Real, b : Real | f(a,b))no 'letrec' - forward lambda references allowed30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 10 11. Implied Functionality - TemplatesSet(String) Set(T)collection types have a magic T in OCL 2.4T is a type template parameter in OCL 2.5supports UML templatestemplated types/operations but not packages/...parameterised by types/literals but not operations/...(T) rather than in OCL expressionsexperimental use of had grammar challenges30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 11 12. Implied Functionality - ReflectionClassifier::allInstances() : Set(T) in OCL 2.4OclAny::oclType() : Classifier in OCL 2.4informal declarations, magic TMyType::allInstances().myPropertyunspecified apparent type utilityOclAny::oclType() : typeof(OclSelf) in OCL 2.5OclAny::allInstances() : Set(OclSelf) in OCL 2.5OclSelf - the apparent type of selftypeof(X) - Class with instance lowerbound of XmyType.oclType().ownedOperations30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 12 13. Implied functionality - type constructionobject construction would be usefulTuple syntax re-useable Tuple{name:type=value}object construction has a side effect - not OCLdef: f(n:String): MyType = MyType{n=name}inv: f('me') = f('me')constructions must create 'shared' object'shadow' object construction is possibleshadow is a Tuple with same named propertiesdistinct Tuples equal by valuereal object created when exploited by QVT30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 13 14. Implied functionality - multi-returnsUML supports multiple function returnsOCL 2.4 doesn'tSolution, wrap multiple returns up as a Tuple'UML': f(in a:A, in b:B, inout c:C, out d:D)becomesOCL: f(a:B, b:B, c:C) : Tuple{c:C, d:D}body: Tuple{c = ..., d = ...}post: result.c = ...post: result.d = ...post: result = Tuple{c = ..., d = ...}30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 14 15. Syntax sugar - elseifOCL 2.4 cumbersome endifsif c1 then v1else if c2 then v2else if c3 then v3else v4endifendifendifOCL 2.5 simplerif c1 then v1elseif c2 then v2elseif c3 then v3else v4endifjust a CS rewrite30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 15 16. Syntax sugar - typesafe ifOCL 2.4 cumbersome re-typingif x.oclIsKindOf(MyType) thenlet t : MyType = x.oclAsType(MyType) in f(t)else ...endifOCL 2.5 simplerif t : MyType = x thenf(t)else ...endifspecial case of a pattern match30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 16 17. Syntax sugar - safe navigationOCL 2.4 vulnerable to navigation on nullsx.ys.z x.ys->collect(z)is invalid if x or any x.ys is nullif x null then x.ys->excluding(null).z else null endifOCL 2.5 offers safe navigationx.?ys.?z x.?ys->?collect(z)simple CS rewrite30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 17 18. Syntax sugar - iterator alternativesOCL 2.4 source->iteration(iterators | body)e.g. s->forAll(body)s->forAll(i | body)s->forAll(i : Integer | body)OCL 2.5 iterator may instead have domainforAll(i in s | body)forAll(i : Integer in s | body)OCL 2.5 iterator may be allInstancesforAll(c in Class | body)Class::allInstances()->forAll(c | body)type/property ambiguity resolved to type30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 18 19. Iteration co-indexesOCL 2.4 cumbersome to obtain iteration indexparameters->forAll(p |let i = parameters->indexOf(p),a = arguments->at(i)in a.type->conformsTo(p.type))For ordered collectionsparameters->forAll(p[i] |let a = arguments->at(i)in a.type->conformsTo(p.type))Implementation can be better than syntax sugaradd coIndexName to AS30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 19 20. Syntax sugar - collection comprehensionOCL 2.4 iterationssource->iteration(iterator : T | body)OCL 2.5 iteration alternative with initializeriteration(iterator : T in source | body)OCL 2.4 collection literalSet{1, 4, 9, 16}OCL 2.5 collection comprehensionSequence{1..4}->Set{i | i*i}Set{i in Sequence{1..4} | i*i}rewrite ofSequence{1..4}->collect(i | i*i)->asSet()30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 20 21. Syntax sugar - varargsOCL 2.4 invocation arguments must matchf(a : Integer, b : String[*])may be invoked asf(1, Set{'a'})OCL 2.5 allows enumeration of final collectionf(1) f(1, 'a') f(1, 'a', 'b')WFRs prohibit overload ambiguities30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 21 22. Library - inadequate extensibilityOCL 2.4 Standard Library - mandatorynot a model, not referenceable, not extensibleOCL 2.5 Standard Library - replaceableOCL Pivot model, referenceable, extensibleopen market to domain-specific librariesOCL 2.4 MonolithOCL 2.5 Modular, extensibleat least States, Messages optionalprobably Reflection optionaloptional => tooling regeneration for changes30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 22 23. Library - MapOCL 2.4 cumbersomelet myMap = Set{Tuple{key:String=...,value:Integer=...}}in myMap->includes{Tuple{key='five',value=5})inaccurate Set{Tuple} not Set{String}OCL 2.5 Map (and OrderedMap)let myMap : Map(String,Integer) = ...in myMap->includes('five',5)Obvious, but not quite so obviousOCL-like coherent interface design welcome30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 23 24. Library - selectCollectQVTo (imperative):source->xcollectselect(iterators; result := body | guard)OCL 2.5source->selectCollect(iterators | guard | body)rewrite ofsource->select(iterators | guard)->collect(iterators | body)30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 24 25. Complete OCL - Package invariantsOCL 2.4 only classes have invariantsall invariants must be allocated to a classOCL 2.5, packages may have invariants toopackage Mineinv PackageInvariant: ....30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 25 26. A Use Case (1)All Classes have capitalized namesOCL 2.4 correctcontext Classinv: let n = name.at(1) in n = n.toUpperCase()naivecontext Classinv: Class::allInstances()->forAll(c |let n = c.name.at(1) in n = n.toUpperCase())OCL 2.5 betterpackage UMLinv: forAll(c in Class | c.name.isCapitalized())30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 26 27. A Use Case (2)package UMLinv: forAll(c in Class | c.name.isCapitalized())New: iterator syntaxesforAll(c in Class ...New: Package Invariants for global truthslocalizing allInstances() is an implementation detailOld: helper function (for library type)context Stringdef: isCapitalized() : Boolean =let n = at(1) in n = n.toUpperCase()30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 27 28. White Box view of OCLOCLConcrete SyntaxStandard LibrarySemanticsUsersLoaderAbstractSyntaxSaverSpecification totally inadequateMissing / UnimplementableRewrite / DesignModelsXMI30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 29 29. XMI Model interchange - goalsmodel state must be captured by objectsno magicevery state object must be referenceableno holesevery state object must be persistableno non-derived secret objectspersisted objects must be reloadableno irreversible conversionsOCL-specific XMI loader/saver undesirable30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 30 30. XMI Model interchange - OCL 2.4model state must be captured by objectsIterations are not modelledConstraint does not exist in EMOFevery state object must be referenceableComplete OCL objects have no URIOCL Standard Library elements have no URIevery state object must be persistableCollection/Tuple specializations are unspecifiedpersisted objects must be reloadableonly if vendors provide a non-standard solution30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 31 31. OCL principle and practiceSpecification-time,MetamodelsDesign-time,compile-time,User ModelsRun-time UserInstances/ValuesUser Types Specification Typesdon't care CMOF::ClassEClass,OCL-text,OCLExpressionEObject,intUML::Class,EMOF::Class,OCL::OCLExpressionObjectValueIntegerValue30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 32 32. UML 2.0...2.4 Core::Basic PackagesinelegantClass/Typesingular superClassobsolete ownedAttributevague rootefficient30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 33 33. UML 2.5 Packagessame ineleganciesnew inefficienciesextra inheritancesmulti-level property subsetsproperty redefinitionproperty derivation30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 34 34. OCL 2.5 PivotSpecification-time,MetamodelsDesign-time,compile-time,User ModelsRun-time UserInstances/ValuesUser Types Specification TypesalignUML::Class OCL::ClassEClass,OCL-text,OCLExpressionEObject,intPivotOCL::Class,OCL::OCLExpressionObjectValueIntegerValueMtoMloadMtoMsemanticsMtoM30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 35 35. Specification Time MtoMFrom:UML 2.5 metamodelOCL 2.5 metamodel(optional vendor-specific metamodel)Using QVTo transformation, Control Modeldelete/merge/rename/redefine Package/Class/...To:OCL Pivot metamodele.g. Type,Classifier,Class => ClassClass::ownedAttribute => Class::ownedProperties30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 36 36. Compile Time MtoMLoadUML/EMOF/Ecore/... Model(s)OCL Standard Library Model(s)User Complete OCL Document(s)Normalize to OCL Pivot Modelunified PrimitiveTypesunified synthetic types (Collections, Tuples)conformance/inheritance of OclAny/OclElementcomplete classesmake unnavigable opposites navigabledetermine stereotype properties30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 37 37. Run time 'MtoM'Conversion to Pivot Values inefficientRun-time mapping defines observable semanticsSimple OCL just executesType-dependent expressionseither map Pivot conformance to user type systemor map user type system to Pivot conformanceReflectionload user type system as Pivot modelreflection uses Pivot model30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 38 38. Objects to ReferenceEssentialOCL is the package exposing theminimal OCL required to work with EMOFno Constraint or OpaqueExpression thenNote - It is expected that further revisions of thisspecification will provide explicitly the completeset of well-formedness rules and additionaloperations that apply to Core::Basic - to replacethe lazy re-interpretation statement we are usinghere.UML 2.5 removes Core::Basic30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 39 39. Metamodel goalsUML - analysis / designpowerful metamodeling capabilitiesinefficient, not executedEMOF (or Ecore) - run-time / executionessential metamodeling capabilitiesefficientOCL - executable specificationrich metamodeling capabilitiesefficient, executable30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 40 40. OCL '2.5' Partial Packagesplural, consistent namesownedPropertiesexplicit rootefficientownedClassesType only for templatesno subsetsno redefinitionno primary derivation30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 41 41. OCL '2.5' Complete Packages30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 42 42. OCL '2.5' Complete Packagesprimary derived propertiesadditional helpful all-models derived properties e.g.context CompleteModeldef: allClasses : Set(Class) =partialModels->closure(ownedPackages).ownedClassespotentially very efficientcaches for derivationsconstant timename lookupoperation overload lookupconformance type test30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 43 43. Inadequate OCL 2.4 ASOpen classes - Complete OCL extensionsConstraintsLambda TypesReflectionIterations30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 44 44. Inadequate UML alignmenttemplatesbounded collectionsnon-navigable oppositesqualified associationsstereotype navigationoperation overloadingOclAny conformance30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 45 45. Inadequate Exposition (7)Clause 7 - tutorial, overviewunfortunate number of mistakesExtract as a companion volumeauthors wantedensure examples are tool checked30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 46 46. Inadequate Exposition (8)Clause 8 - Abstract Syntaxunforgivable number of mistakes'8a' Auto-generate from Pivot Modelsincluding all the Class, CompleteClass, ...'8b' Use of OCL Constraint in UML'8c' compile time MtoM (loading/normalization)30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 47 47. Inadequate Exposition (9)Clause 9 - Concrete Syntax, Grammarelusive grammar, optimistic disambiguation'9a' Essential OCL: Auto-generateCS from CS Modelsgrammar from 'Xtext' modelsCS2AS from CS2AS modelsdisambiguation from CS2CS modelslookup from Lookup models'9b' Same again for Complete OCL30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 48 48. Inadequate Exposition (10)Clause 10 - Semanticsunforgivable number of mistakesAuto-generatefrom semantics structural Models30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 49 49. Inadequate Exposition (11)Clause 11 - OCL Standard LibraryinconsistentAuto-generatefrom OCL Standrad Library model30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 50 50. Inadequate Exposition (11)Clause 11 - OCL Standard LibraryinconsistentAuto-generatefrom OCL Standrad Library model30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 51 51. Inadequate Exposition (12)Clause 12 - Use Of OCL in UMLinconsistent, very incompleteReorganiseComplete OCL AS => Clause 8Complete OCL CS/grammar => Clause '9b'OCL in UML=> Clause '12a'30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 52 52. Inadequate Exposition (13)Clause 13 - Basic OCL, Essential OCLlargely a fairy storyRewritespecification time MtoM (UML alignment)30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 53 53. Inadequate Exposition (A)Annex A - Formal SemanticsLaTeX => FrameMaker corruptionsOut of date: OrderedSet, closure(), ...Needs: templates, lambdas, ...Rewrite using Isabelle semanticscompanion document using LaTeXnot necessarily 100% of language30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 54 54. SummaryOCL 2.5rewrite, 'no-change', auto-generated from modelsUML-alignedbounded collectionsmodeling requires formalitylambdas, templates, reflectionenhanced concrete syntaxelseif, safe-navogation, ...defined load/save activtiesinterchangeable abstract syntax via XMIextensible30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 55 55. OCL specification claims (1)OCL 'works with UML'UML 2.0...2.4 Core::Basic perhapsUML 2.5 inefficientno Complete classesOCL 'works with EMOF'no OpaqueExpression - Constraintsno unnavigable oppositesno stereotypesno templates ....30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 56 56. OCL specification claims (2)OCL 'is aligned with UML''aligned' not 'identical to'Recreate UML 2.4 Core::Basic from UML 2.5use a QVTo Model-to-Model transformationcorrect unhelpful aspectsadd specified OCL 2.4 aspectsadd solutions to un/under-specified aspects30-Sept-2014 OCL 2.5 Plans Made available under EPL 1.0 57