1 / 28

A Metamodeling Approach to Pattern Specification

A Metamodeling Approach to Pattern Specification. Maged Elaasar 1,2 , Dr. Lionel Briand 1 , Dr. Yvan Labiche 1 1 Carleton University, Ottawa, 2 IBM Rational Ottawa Lab. MoDELS 2006, Genova , Italy. The Need for Model Pattern Specification & Detection.

rmaxine
Télécharger la présentation

A Metamodeling Approach to Pattern Specification

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. A Metamodeling Approach to Pattern Specification Maged Elaasar1,2, Dr. Lionel Briand1, Dr. Yvan Labiche1 1Carleton University, Ottawa, 2IBM Rational Ottawa Lab MoDELS 2006, Genova, Italy

  2. The Need for Model Pattern Specification & Detection • Following MDA means models are first class artifacts • Model analysis ensures quality of models • Various techniques of model analysis are researched • Structural Analysis: Architectural Discovery, Anti-Pattern Detection • Consistency and Completeness Analysis • A common requirement to those analysis techniques is finding patterns • Patterns are recurring structures that are either desirable or undesirable • Patterns need to be specified before being detected detected in

  3. Pattern Specification and Detection in the Literature • Mathematical Approaches • Specify a pattern using a mathematical notation (logic) • Convert M1 model into the same mathematical notation • Solve the system and map result back to model • Highlights : • need mathematics skills • integration issues with CASE tools • Metamodeling Approaches • Specify a pattern as an M2 model • Use specification to guide a detection algorithm in navigating the M1 model • Highlights: • have high coupling with UML • lack scalability and complexity management features • specify M2 patterns using M1 constructs • unfamiliar architecture and notation

  4. Objectives for Pattern Specification and Detection • Methodology • Patterns are specified as a model using a modeling process • Patterns are specified for any (MOF-based) language • Specification is concise, precise and scalable • Specifications is used to derive detection algorithms • Specifications semantics allows for configuring detection algorithm • Tooling • A visual pattern specification editor • A code generator for detection algorithms • A pattern detection environment • Specifying a representative set of patterns (e.g. structural, behavioral, anti-patterns)

  5. UML Metamodel UML Metamodel UML Metamodel UML Metamodel Modeling Languages User Models The Metamodeling Architecture • MOF is a metamodeling language (M3) • Modeling languages are defined as instances of MOF (M2) • User models are defined as instances of modeling languages (M1) MOF M3 - MetametaModel Instance of M2 - MetaModel Instance of M1 - Model Metamodeling Architecture

  6. Eclipse Modeling Framework (EMF) • We consider a subset of MOF called Essential MOF (EMOF) • EMOF has simple class diagram semantics • EMF provides an implementation of EMOF: the Ecore metamodel

  7. UML Metamodel UML Metamodel UML Metamodel UML Metamodel UML Metamodel UML Metamodel UML Metamodel UML Metamodel Patterns Pattern Instances Modeling Languages User Models Our Solution: Pattern Modeling Framework (PMF) • PMF is a new framework for pattern specification and detection • PMF provides a pattern specification language called “Epattern” • PMF provides a parallel metamodeling architecture • Epattern extends Ecore with pattern specification semantics (M3) • Patterns are defined as instances of Epattern (M2) • Pattern instances are defined as instances of Patterns (M1) Ecore (EMOF) Epattern M3 - MetametaModel extends Instance of Instance of defined for M2 - MetaModel Instance of Instance of defined for M1 - Model EMF Architecture PMF Architecture

  8. Epattern Metamodel  Ecore Metamodel • EPattern: a meta-class specifying the context of a pattern • ERole: a meta-reference specifying a role played by a pattern participant • EConstraint: a boolean meta-operation specifying a pattern well-formedness rule • EConnector: an meta-element specifying a relationship between two roles • EPort: a meta-reference specifying a composition point for a pattern • EAssociation: a meta-class specifying a new derived relationship in pattern metamodel

  9. Epattern Notation 1/2

  10. Epattern Notation 2/2

  11. Epattern Modeling Process 1. Understand Pattern Structure 2. Create EPattern 2.1. Add ERoles 2.2. Add EConnectors 2.3. Add EConstraints 2.4. Add EPorts 2.5. Reduce Complexity 4. Generate Detection Algorithm 5. Run Detection Algorithm 6. Inspect Detection Result

  12. A pattern example: Composite Pattern

  13. 1. Understand Pattern Structure <<Interface>> Component Children * Composite Pattern Leaf2 Leaf1 Composite - compose (child: Component) * - interfaceRealization InterfaceRealization 1 - contract 1 - implementingClassifier 1 * - class -ownedOperation Interface Class Operation Simplified UML2 Meta-Model * - ownedAttribute 0..1 - type Classifier Property

  14. composition self.children.aggregation = Aggregation.Composite and self.children.upperBound = -1 self.compose.ownedParameter->size() = 1 and self.compose.ownedParameter->at(1) .type = self.component parameter 2. Create EPattern gof.structural.Composite • Add ERoles • Add EConnectors • Add EConstraints • Add EPorts component: Interface type 2 1 3 1 contract contract 1 2 2 1 realization1: InterfaceRealization [ * ] realization2: InterfaceRealization children: Property 1 2 1 interfaceRealization interfaceRealization ownedAttribute implementingClassifier implementingClassifier 1 3 leaf: Class [ * ] composite: Class 2 class 1 class 1 compositePort: Class ownedOperation 1 compose: Operation 1

  15. * Composition * composingClassifier composedType Implementation Interface * * BehavioredClassifier implementedInterface implementingClassifier StructuredClassifier Type 3. Reduce Specification Complexity gof.structural.Composite composition self.children.aggregation = Aggregation.Composite and self.children.upperBound = -1 component: Interface type 2 1 3 1 contract contract 1 2 2 1 realization1: InterfaceRealization [ * ] realization2: InterfaceRealization children: Property 1 2 1 interfaceRealization interfaceRealization ownedAttribute implementingClassifier implementingClassifier 1 3 leaf: Class [ * ] composite: Class class 2 1 class 1 compositePort: Class self.compose.ownedParameter->size() = 1 and self.compose.ownedParameter->at(1) .type = self.component parameter ownedOperation 1 compose: Operation 1

  16. * Composition * composingClassifier composedType Implementation Interface * * BehavioredClassifier implementedInterface implementingClassifier Type StructuredClassifier 3. Reduce Specification Complexity gof.structural.Composite component: Interface composedType 2 1 3 1 implementedInterface implementedInterface implementingClassifier implementingClassifier composingClassifier 1 3 leaf: Class [ * ] composite: Class 2 1 class compositePort: Class 1 self.compose.ownedParameter->size() = 1 and self.compose.ownedParameter->at(1) .type = self.component parameter ownedOperation 1 compose: Operation 1

  17. 3. Other Ways of Managing Complexity (WIP) • Pattern Composition: patterns are composed of smaller patterns • Pattern Inheritance: patterns are organized into hierarchies • Pattern Refinement: inherited pattern semantics can be redefined • Pattern Genericity: patterns are defined as templates SmallPattern SuperPattern SuperPattern PatternTemplate role1: Operation role1: Classifier role1: Classifier role1: Classifier role1.attributes.size() = <n> role2: Parameter BigPattern SubPattern SubPattern PatternTemplateInstance role1: Classifier role1: Class role1: Class role1: Classifier role1.attributes.size() = 2 role2: Class role2: SmallPattern composition inheritance refinement genericity

  18. Conclusion • Motivation • Pattern detection is an important technique for model analysis • Patterns need to be formally specified before being detected • Solution (PMF) • Complies with the metamodeling architecture • Supports patterns of any EMOF-based language (even cross language patterns) • Provides ways to cope with pattern complexity and scalability • Provides a visual, systematic specification process • Future Work: • Well-formedness rules for Epattern • Other complexity management features • Derivation of a detection algorithm • Tooling (editor and algorithm generator) • Specify/detect various kinds of patterns

  19. Thank You

  20. 3. Reduce Complexity with Composition classPort : Class Singleton Constructor PropertyType class : Class [1..1] class instanceProperty.type = class constructor.name =class.name class class ownedAttribute ownedOperation ownedOperation instanceProperty : Property [1..1] instanceAccessor : Operation [1..1] constructor : Operation [1..1] operation Property Accessor AccessorType instanceProperty.visibility = VisinilityKind.Private and instanceProperty.isStatic = true instanceAccessor.visibility <> VisibilityKind.Private and instanceAccessor.isStatic = true returnResult.type = class ownedParameter returnResult returnResult : Parameter [1..1] parameter : Parameter [0..0]

  21. 3. Reduce Complexity with Composition classPort : Class Singleton class : Class [1..1] class class class ownedAttribute ownedOperation ownedOperation instanceProperty : InstanceProperty [1..1] instanceAccessor : InstanceAccessor [1..1] constructor : Constructor [1..1] operationPort : Operation operationPort : Operation InstanceAccessor Constructor propertyPort : Property InstanceProperty operation : Operation [1..1] operation : Operation [1..1] operation Signature property : Property [1..1] Type Constructor operation.visibility <> VisibilityKind.Private and operation.isStatic = true parameter.type = operation.class operation.name = operation.class.name Signature property.visibility = VisinilityKind.Private and property.isStatic = true and property.type = property.class ownedParameter returnResult parameter : Parameter [1..1] parameter : Parameter [0..0]

  22. 4. Generate Detection Algorithm (Work In Progress) EPattern Query Class EPort Execute Method: starts the execution at the attached role ERole Bind Method: checks and binds conforming objects to role EConnector Traverse Method: extracts related objects at other end EConstraint Verify Method: checks the constraint on candidate objects EAssociation Association Class EAssociationEnd Derive Method: derives the related objects at the other end

  23. 5. Run Detection Algorithm (Work In Progress) CompositePattern • The algorithm’s control flow will be affected by: • The input port to start detection from • The order of outgoing connectors from every role • The order of constraints attached to every role component: Interface composedType 2 1 3 1 implementedInterface implementedInterface implementingClassifier implementingClassifier composingClassifier 1 3 leaf: Class [ * ] composite: Class 2 class compositePort: Class 1 compose.ownedParameter->size() = 1 and compose.ownedParameter->at(1) .isOCLOfKind(component) parameter ownedOperation 1 compose: Operation 1

  24. 6. Inspect Detection Result (Work In Progress) Composite • composite: Class • component: Interface • leaf: Class • compose: Operation instanceof CompositeInstance1 • composite= • component = • leaf = • compose = Composite Command

  25. name: eType [lowerBound…uperBound] eOppositeEnd.eType 1 eType 2 name: eType [lowerBound…uperBound] name: eType 2 1 1 2 name namespace.Name expression

  26. Pattern :Package :Package :Package ownedClasses ownedClasses :Observer [*] :Class :Class observedClasses

  27. 1. Execute Step Candidate Elements … 1.1 Filter Candidate Elements For Every Port Candidate Elements 1.2 Create Empty Pattern Instance Pattern Instances 1.3 Call Bind Step For Every Port’s Role 2. Bind Step Candidate Elements 2.1 Check Pattern Instance For Bound Role Pattern Instance 2.2 Filter Candidate Elements 2.3 Clone Pattern Instance And Bind Role 2.4 Call Verify Steps For Every Constraint 2.5 Call Connect Steps for Every Connector Pattern Instances 2.6 Check For Optional Role

  28. 3. Verify Step Pattern Instance 3.1 Check Pattern Instance For Bound Constrained Roles 3.2 Check Constraint On Pattern Instance Boolean 4. Connect Step Pattern Instance 4.1 Get Element From Start Role 4.2 Traverse Connector From Start To End Roles Pattern Instances 4.3 Call Bind Step for End Role

More Related