flexible modelling
play

FLEXIBLE MODELLING BASED ON FACETS Juan de Lara 1 Joint work with E. - PowerPoint PPT Presentation

FLEXIBLE MODELLING BASED ON FACETS Juan de Lara 1 Joint work with E. Guerra 1 , J. Kienzle 2 , Y. Hattab 2 1 Universidad Autnoma de Madrid (Spain) 2 McGill University (Canada) AGENDA Context: Model-driven Engineering Motivation Facets


  1. FLEXIBLE MODELLING BASED ON FACETS Juan de Lara 1 Joint work with E. Guerra 1 , J. Kienzle 2 , Y. Hattab 2 1 Universidad Autónoma de Madrid (Spain) 2 McGill University (Canada)

  2. AGENDA Context: Model-driven Engineering Motivation Facets Interfaces and laws Tool support Case studies Conclusions and future work 2

  3. CONTEXT: MODEL- DRIVEN ENGINEERING For specific domains • Avoid coding the same solutions over and over • Families of applications Domain-Specific Modelling Languages (DSLs) Code Generator • Syntax defined by a meta- model • Code generators, simulators, model transformations Modelling, validation and automatic generation of telephony services 3

  4. MDE: DOMAIN-SPECIFIC LANGUAGES Abstract syntax • Meta-model • Integrity constraints (OCL) Concrete syntax • Graphical • Textual • Tabular, etc Semantics • Operational, denotational, etc Services • Refactorings, code generators, simulators, etc 4

  5. DOMAIN SPECIFIC MODELLING LANGUAGES Describe the structure of the domain • Relevant primitives and abstractions • Relations, features • Explicit expert knowledge 5 MetaEdit+

  6. DOMAIN SPECIFIC MODELLING LANGUAGES DSMLs need not be graphical… 6 xText

  7. MODELS AND META-MODELS The abstract syntax of DSMLs is defined through a meta-model Factory meta-model inps • Classes * 1..* Conveyor Machine • outs Attributes 1..* * • Relations * parts Part Generator Assembler Terminator 7

  8. MODELS AND META-MODELS The abstract syntax of DSMLs is defined through a meta-model Factory meta-model inps • Classes * 1..* Conveyor Machine • outs Attributes 1..* * • Relations * parts «conforms to» Part Generator Assembler Terminator g:Generator p2: Part p2: Part outs inps c1:Conveyor inps outs a:Assembler c3:Conveyor t:Terminator outs c2:Conveyor inps 8

  9. OCL CONSTRAINTS Object Constraint Language Factory meta-model Factory meta-model inps inps Well-formedness rules, which * * 1..* 1..* Conveyor Conveyor Machine Machine every model should satisfy outs outs 1..* 1..* * * * parts * parts Based on First-Order Logic Part Part Generator Generator Assembler Assembler Terminator Terminator context Generator inv : context Generator inv : self .inps->isEmpty() and self .outs->size()>0 self .inps->isEmpty() and self.outs->size()>0 «conforms to» context Terminator inv : self .outs->isEmpty() and self .inps->size()>0 context Assembler inv : c:Conveyor self .inps->size()>0 and self .outs.size()>0 inps … g:Generator 9

  10. MODELS AND META-MODELS Models are represented using concrete syntax • Visual • Textual No need for a 1-1 correspondence between abstract and concrete syntax elements asse 10

  11. MODEL TRANSFORMATIONS Models need to be manipulated for • Simulation in-place transformations • Optimization/refactoring • Generating another model • Generating code 11 …

  12. MODEL TRANSFORMATIONS Models need to be manipulated for • Simulation • Optimization/refactoring model-to-model • Generating another model transformations • Generating code Target Source 12

  13. MODEL TRANSFORMATIONS Models need to be manipulated for • Simulation • Optimization/refactoring model-to-model • Generating another model transformations • Generating code Transformation developer from to Transformation MM src MM tar definition «conforms to» «conforms to» Transformation M src M tar execution Final user 13

  14. MODEL TRANSFORMATIONS Models need to be manipulated for • Simulation • Optimization/refactoring query and • Generating another model model navigation • Generating code Template languages 14

  15. Very nice… Where’s the ugly? 15

  16. SOME LIMITATIONS … Meta-model Person fullName: String Model-driven Engineering age: int female: boolean • Models are the principal artifacts «conforms» • Models conform to a meta-model Model :Person Objects are closed fullName =“ Homer ” age=36 • Created using classes as templates female=false • Slots, types, and constraints cannot be changed This rigidity makes some MDE scenarios difficult • Reuse of model transformations • Model extension • Multi-view modelling 16 • …

  17. MOTIVATION: REUSE Census Metrics operation Group avg(): Real { Element Person if (elems.isEmpty()) return 0; fullName: String quantity: int return elems.quantity.sum()/ 0..1 age: int elems.size(); elems * spouse female: boolean } Group address Address street: String Calculate average age of all male city: String adults in Springfield «conforms» Springfield: Census Can we reuse operation avg on Census models? :Person :Person fullName =“ Homer ” fullName =“ Todd ” • Retype some Persons as Elements age=36 age=8 • Create a Group containing all male female=false female=false 17 … adults

  18. MOTIVATION: MODEL EXTENSION Employment Census Employee minSalary inv : name: String self .salary > 15000 Person salary: double fullName: String 0..1 ssNumber: int age: int active: boolean spouse female: boolean employees * reportsTo address Company Owner Address name: String name: String street: String vatId: String city: String belongsTo «conforms» Springfield: Census Can we extend existing Person objects with Employment info? :Person :Person • Retype some Persons as fullName =“ Homer ” fullName =“ Todd ” Employees or Owners age=36 age=8 female=false female=false 18 • Add corresponding slots and … constraints

  19. IN THIS TALK … New modelling mechanism: the facet • brings flexibility and dynamism to modelling • lightweight: facets are just objects Objects become open • can acquire and drop slots, types and constraints Facet laws • specify when objects acquire/drop facets Practical implementation • on top of metaDepth, a textual meta-modelling tool 19

  20. WHAT’S A FACET? A facet is an object • becomes part of another one(s), called the host object(s), • the slots of the facet become transparently accessible from the host, which also acquires the type and constraints of the facet. A host object can acquire and drop facets dynamically Springfield host Springfield :Census facet object :Census :Employment homer :Person homer :Person :Employee : Employment fullName = “ Homer ” age= 57 age= 57 emp: Employee female= false emp: Employee female= false fullName= name = “ Homer ” name = “ Homer ” salary=47500 salary=47500 ssNumber=12345 ssNumber=12345 emp: Employee[1] 20 active=true active=true

  21. WHAT’S A FACET? Census Employment Object homer receives: Employee minSalary inv : name: String salary > 15000 • Slots ( name , salary , ssNumber , active ) … salary: double • Type ( Employee ) ssNumber: int active: boolean • Constraints ( minSalary ) … From its emp facet «conforms» Springfield Host and facet slots may be synchronized «conforms» :Census :Employment • fullName and name homer :Person :Employee • Changing either one modifies the other age= 57 emp: Employee female= false Slot name ambiguity fullName= name = “ Homer ” • Resolved by facet name ( homer.emp ) salary=47500 ssNumber=12345 21 active=true Shared facets and several facets in hosts

  22. FACET MANAGEMENT A DSL for adding/removing facets to objects Selection of host objects by id Selection of host objects by properties addFacet homer addFacet emp: Employment.Employee $Person.allInstances ()→select(age>17)$ with { emp: Employment.Employee with {…} name = fullName [ equality ] Query-based host selection salary = 22345 addFacet  h:Person, w:Person  where ssNumber = 12345 active = true $h.spouse=w$ emp: Employment.Employee with {…} } Explicit host selection Pattern-based host selection (similar commands for removing a facet) 22

  23. FACET MANAGEMENT One-to-many and many-to-one host/facet relations are supported addFacet homer addFacet $Person.all ()→select(age>17)$ dayJob: Employment.Employee with { name = fullName [ equality ] emp: Employment.Employee with {…} reuse salary = 15000 ssNumber = 12345 Facet shared among all active = true selected host objects } nightJob: Employment.Employee with { name = fullName [ equality ] salary = 16400 ssNumber = dayJob.ssNumber [ equality ] active = dayJob.active [ equality ] } 23 Several facets in same host object

  24. REACTIVE FIELD ADAPTERS addFacet homer emp: Employment.Employee with { ssNumber = 12345 // value semantics: literals salary = $100* self .age$ // value semantics: expressions name = fullName [ equality ] // reference semantics: bx synchronization active = [ self .age < 65] // reference semantics: reactive field adapter } Coupled change dependencies • active = [ self .age < 65]  When age changes, active is updated • name = fullName [ equality ]  Eq. to name = [fullName] [fullName=name] N-ary depedencies • salary = [100* self .age] [rich = self .salary > 10000] • ill-behaved: name = [fullName] [fullName = ’Mr. ’. concat(name)] 24 • Safety policy: each field is evaluated once within a cycle

Recommend


More recommend