Download presentation
Presentation is loading. Please wait.
Published byShannon Fitzgerald Modified over 9 years ago
1
® IBM Software Group 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
2
IBM Software Group | Rational software 9 th MoDELS Conference, Genoa, Italy, October 1 st, 2006 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
IBM Software Group | Rational software 9 th MoDELS Conference, Genoa, Italy, October 1 st, 2006 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
IBM Software Group | Rational software 9 th MoDELS Conference, Genoa, Italy, October 1 st, 2006 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
IBM Software Group | Rational software 9 th MoDELS Conference, Genoa, Italy, October 1 st, 2006 5 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) UML Metamodel UML Metamodel Modeling Languages Instance of UML Metamodel UML Metamodel User Models MOF Instance of M3 - MetametaModel M2 - MetaModel M1 - Model Metamodeling Architecture
6
IBM Software Group | Rational software 9 th MoDELS Conference, Genoa, Italy, October 1 st, 2006 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
IBM Software Group | Rational software 9 th MoDELS Conference, Genoa, Italy, October 1 st, 2006 7 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) UML Metamodel UML Metamodel Modeling Languages Instance of UML Metamodel UML Metamodel User Models Ecore (EMOF) Instance of UML Metamodel UML Metamodel Patterns Instance of UML Metamodel UML Metamodel Pattern Instances Epattern Instance of extends defined for defined for M3 - MetametaModel M2 - MetaModel M1 - Model EMF Architecture PMF Architecture
8
IBM Software Group | Rational software 9 th MoDELS Conference, Genoa, Italy, October 1 st, 2006 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
IBM Software Group | Rational software 9 th MoDELS Conference, Genoa, Italy, October 1 st, 2006 9 Epattern Notation 1/2
10
IBM Software Group | Rational software 9 th MoDELS Conference, Genoa, Italy, October 1 st, 2006 10 Epattern Notation 2/2
11
IBM Software Group | Rational software 9 th MoDELS Conference, Genoa, Italy, October 1 st, 2006 11 Epattern Modeling Process 1. Understand Pattern Structure 2. Create EPattern 4. Generate Detection Algorithm 5. Run Detection Algorithm 6. Inspect Detection Result 2.1. Add ERoles 2.2. Add EConnectors 2.3. Add EConstraints 2.4. Add EPorts 2.5. Reduce Complexity
12
IBM Software Group | Rational software 9 th MoDELS Conference, Genoa, Italy, October 1 st, 2006 12 A pattern example: Composite Pattern
13
IBM Software Group | Rational software 9 th MoDELS Conference, Genoa, Italy, October 1 st, 2006 13 1. Understand Pattern Structure > Component CompositeLeaf1Leaf2 - compose (child: Component) Children * InterfaceRealization ClassInterface Property Operation Classifier Composite Pattern Simplified UML2 Meta-Model 1 * - class -ownedOperation 0..1 - type * - ownedAttribute 1 - implementingClassifier 1 - contract * - interfaceRealization
14
IBM Software Group | Rational software 9 th MoDELS Conference, Genoa, Italy, October 1 st, 2006 14 2. Create EPattern Add ERoles Add EConnectors Add EConstraints Add EPorts component: Interface realization1: InterfaceRealization [ * ] composite: Class realization2: InterfaceRealizationchildren: Property compose: Operation leaf: Class [ * ] contract implementingClassifier ownedAttribute type ownedOperation compositePort: Class gof.structural.Composite class interfaceRealization implementingClassifier interfaceRealization class self.children.aggregation = Aggregation.Composite and self.children.upperBound = -1 composition self.compose.ownedParameter->size() = 1 and self.compose.ownedParameter->at(1).type = self.component parameter 1 3 1 1 2 21 2 1 3 2 1 2 1 1 1 1 1
15
IBM Software Group | Rational software 9 th MoDELS Conference, Genoa, Italy, October 1 st, 2006 15 3. Reduce Specification Complexity component: Interface realization1: InterfaceRealization [ * ] composite: Class realization2: InterfaceRealizationchildren: Property compose: Operation leaf: Class [ * ] contract implementingClassifier ownedAttribute type ownedOperation self.compose.ownedParameter->size() = 1 and self.compose.ownedParameter->at(1).type = self.component self.children.aggregation = Aggregation.Composite and self.children.upperBound = -1 compositePort: Class class interfaceRealization implementingClassifier interfaceRealization class composition parameter 1 3 1 1 2 21 2 1 3 2 1 2 1 1 1 1 InterfaceBehavioredClassifier Implementation implementedInterfaceimplementingClassifier ** StructuredClassifierType Composition composingClassifiercomposedType ** gof.structural.Composite 1
16
IBM Software Group | Rational software 9 th MoDELS Conference, Genoa, Italy, October 1 st, 2006 16 3. Reduce Specification Complexity component: Interface composite: Class compose: Operation leaf: Class [ * ] implementedInterface implementingClassifier ownedOperation compositePort: Classclass implementingClassifier composedType implementedInterface composingClassifier 1 3 1 2 2 31 1 self.compose.ownedParameter->size() = 1 and self.compose.ownedParameter->at(1).type = self.component parameter 1 1 InterfaceBehavioredClassifier Implementation implementedInterfaceimplementingClassifier ** StructuredClassifierType Composition composingClassifiercomposedType ** gof.structural.Composite 1
17
IBM Software Group | Rational software 9 th MoDELS Conference, Genoa, Italy, October 1 st, 2006 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 SubPattern role1: Classifier SuperPattern role1: Classifier role2: Class SubPattern role1: Class SuperPattern role1: Classifier PatternTemplateInstance role1: Classifier PatternTemplate role1: Classifierrole1.attributes.size() = role1.attributes.size() = 2 inheritancerefinementgenericity BigPattern role2: SmallPattern SmallPattern role1: Operation role1: Class composition role2: Parameter
18
IBM Software Group | Rational software 9 th MoDELS Conference, Genoa, Italy, October 1 st, 2006 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
IBM Software Group | Rational software 9 th MoDELS Conference, Genoa, Italy, October 1 st, 2006 19 Thank You
20
IBM Software Group | Rational software 9 th MoDELS Conference, Genoa, Italy, October 1 st, 2006 20 3. Reduce Complexity with Composition Singleton class : Class [1..1] ownedAttribute class ownedOperation classPort : Class constructor : Operation [1..1] constructor.name =class.name Constructor parameter : Parameter [0..0] ownedParameter operation instanceAccessor : Operation [1..1] instanceAccessor.visibility <> VisibilityKind.Private and instanceAccessor.isStatic = true Accessor returnResult : Parameter [1..1] returnResult returnResult.type = class AccessorType instanceProperty : Property [1..1] instanceProperty.visibility = VisinilityKind.Private and instanceProperty.isStatic = true Property instanceProperty.type = class PropertyType
21
IBM Software Group | Rational software 9 th MoDELS Conference, Genoa, Italy, October 1 st, 2006 21 Singleton instanceProperty : InstanceProperty [1..1] instanceAccessor : InstanceAccessor [1..1] constructor : Constructor [1..1] class : Class [1..1] InstanceProperty property : Property [1..1] ownedAttribute class ownedOperation classPort : Class property.visibility = VisinilityKind.Private and property.isStatic = true and property.type = property.class Signature propertyPort : Property Constructor operation : Operation [1..1] operation.name = operation.class.name Constructor operationPort : Operation parameter : Parameter [0..0] ownedParameter operation InstanceAccessor operation : Operation [1..1] operation.visibility <> VisibilityKind.Private and operation.isStatic = true Signature operationPort : Operation parameter : Parameter [1..1] returnResult parameter.type = operation.class Type 3. Reduce Complexity with Composition
22
IBM Software Group | Rational software 9 th MoDELS Conference, Genoa, Italy, October 1 st, 2006 22 4. Generate Detection Algorithm (Work In Progress) Query Class Execute Method: starts the execution at the attached role Bind Method: checks and binds conforming objects to role Traverse Method: extracts related objects at other end Verify Method: checks the constraint on candidate objects Association Class EPattern EPort ERole EConnector EConstraint EAssociation EAssociationEnd Derive Method: derives the related objects at the other end
23
IBM Software Group | Rational software 9 th MoDELS Conference, Genoa, Italy, October 1 st, 2006 23 5. Run Detection Algorithm (Work In Progress) component: Interface composite: Class compose: Operation leaf: Class [ * ] implementedInterface implementingClassifier ownedOperation compositePort: Class CompositePattern class implementingClassifier composedType implementedInterface composingClassifier 1 3 1 2 2 31 1 compose.ownedParameter->size() = 1 and compose.ownedParameter->at(1).isOCLOfKind(component) parameter 1 1 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
24
IBM Software Group | Rational software 9 th MoDELS Conference, Genoa, Italy, October 1 st, 2006 24 6. Inspect Detection Result (Work In Progress) CompositeInstance1 - composite= - component = - leaf = - compose = Composite Command Composite - composite: Class - component: Interface - leaf: Class - compose: Operation instanceof
25
IBM Software Group | Rational software 9 th MoDELS Conference, Genoa, Italy, October 1 st, 2006 25 1 name: eType name: eType [lowerBound…uperBound] 2 namespace.Name name expression 1 2 eType eOppositeEnd.eType 1 2
26
IBM Software Group | Rational software 9 th MoDELS Conference, Genoa, Italy, October 1 st, 2006 26 :Package :Class :Observer [*] Pattern observedClasses ownedClasses :Package
27
IBM Software Group | Rational software 9 th MoDELS Conference, Genoa, Italy, October 1 st, 2006 27 1. Execute Step 1.1 Filter Candidate Elements For Every Port 1.2 Create Empty Pattern Instance 1.3 Call Bind Step For Every Port’s Role Pattern Instances 2. Bind Step 2.1 Check Pattern Instance For Bound Role 2.2 Filter Candidate Elements 2.3 Clone Pattern Instance And Bind Role Candidate Elements Pattern Instances Pattern Instance 2.4 Call Verify Steps For Every Constraint 2.5 Call Connect Steps for Every Connector 2.6 Check For Optional Role Candidate Elements …
28
IBM Software Group | Rational software 9 th MoDELS Conference, Genoa, Italy, October 1 st, 2006 28 3. Verify Step 3.1 Check Pattern Instance For Bound Constrained Roles 3.2 Check Constraint On Pattern Instance Boolean Pattern Instance 4. Connect Step 4.1 Get Element From Start Role 4.2 Traverse Connector From Start To End Roles 4.3 Call Bind Step for End Role Pattern Instances Pattern Instance
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.