A Metamodeling Approach to Pattern Specification - PowerPoint PPT Presentation

1 / 28
About This Presentation
Title:

A Metamodeling Approach to Pattern Specification

Description:

A Metamodeling Approach to Pattern Specification Maged Elaasar1,2, Dr. Lionel Briand1, Dr. Yvan Labiche1 1Carleton University, Ottawa, 2IBM Rational Ottawa Lab – PowerPoint PPT presentation

Number of Views:114
Avg rating:3.0/5.0
Slides: 29
Provided by: Mage199
Category:

less

Transcript and Presenter's Notes

Title: A Metamodeling Approach to Pattern Specification


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
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
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
extends
M3 - MetametaModel
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
ltltInterfacegtgt Component
Children
Composite Pattern
Composite
Leaf1
Leaf2
- compose (child Component)
- interfaceRealization
InterfaceRealization
1 - implementingClassifier
1 - contract
1 -
class -ownedOperation
Class
Interface
Operation
Simplified UML2 Meta-Model
- ownedAttribute
0..1 - type
Property
Classifier
14
2. Create EPattern
gof.structural.Composite
component Interface
type
2
1
3
1
contract
contract
  • Add ERoles
  • Add EConnectors
  • Add EConstraints
  • Add EPorts

2
1
2
1
realization1 InterfaceRealization
realization2 InterfaceRealization
children Property
1
2
1
ownedAttribute
interfaceRealization
interfaceRealization
implementingClassifier
implementingClassifier
1
3
composite Class
leaf Class
class
2
1
class
1
compositePort Class
ownedOperation
1
compose Operation
1
15
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
2
1
2
1
realization1 InterfaceRealization
realization2 InterfaceRealization
children Property
1
2
1
ownedAttribute
interfaceRealization
interfaceRealization
implementingClassifier
implementingClassifier
1
3
composite Class
leaf Class
class
2
1
class
1
compositePort Class
ownedOperation
self.compose.ownedParameter-gtsize() 1 and
self.compose.ownedParameter-gtat(1) .type
self.component
parameter
1
compose Operation
1
16
3. Reduce Specification Complexity
gof.structural.Composite
component Interface
composedType
2
1
3
1
implementedInterface
implementedInterface
implementingClassifier
implementingClassifier
composingClassifier
3
1
composite Class
leaf Class
2
1
compositePort Class
class
1
ownedOperation
self.compose.ownedParameter-gtsize() 1 and
self.compose.ownedParameter-gtat(1) .type
self.component
parameter
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

SuperPattern
SuperPattern
PatternTemplate
SmallPattern
role1 Operation
role1 Classifier
role1 Classifier
role1 Classifier
role1.attributes.size() ltngt
role2 Parameter
SubPattern
SubPattern
PatternTemplateInstance
BigPattern
role1 Classifier
role1 Class
role1 Classifier
role1.attributes.size() 2
role1 Class
role2 Class
role2 SmallPattern
inheritance
refinement
genericity
composition
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
constructor Operation 1..1
instanceAccessor Operation 1..1
operation
Property
Accessor
AccessorType
instanceAccessor.visibility ltgt VisibilityKind.Pri
vate and instanceAccessor.isStatic true
instanceProperty.visibility VisinilityKind.Priva
te and instanceProperty.isStatic true
returnResult.type class
ownedParameter
returnResult
parameter Parameter 0..0
returnResult Parameter 1..1
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
Constructor
InstanceAccessor
propertyPort Property
InstanceProperty
operation Operation 1..1
operation Operation 1..1
operation
Signature
property Property 1..1
Type
Constructor
operation.visibility ltgt 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 0..0
parameter Parameter 1..1
22
4. Generate Detection Algorithm (Work In Progress)
Query Class
EPattern
Execute Method starts the execution at the
attached role
EPort
Bind Method checks and binds conforming objects
to role
ERole
Traverse Method extracts related objects at
other end
EConnector
Verify Method checks the constraint on candidate
objects
EConstraint
Association Class
EAssociation
EAssociationEnd
Derive Method derives the related objects at the
other end
23
5. Run Detection Algorithm (Work In Progress)
CompositePattern
component Interface
composedType
2
1
3
1
implementedInterface
implementedInterface
implementingClassifier
implementingClassifier
composingClassifier
3
1
composite Class
leaf Class
2
compositePort Class
class
1
ownedOperation
compose.ownedParameter-gtsize() 1
and compose.ownedParameter-gtat(1) .isOCLOfKind(com
ponent)
parameter
1
compose Operation
1
  • The algorithms 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
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 lowerBounduperBound
eOppositeEnd.eType
1
eType
2
name eType lowerBounduperBound
name eType
2
1
1
2
name
namespace.Name
expression
26
Pattern
Package
Package
Package
ownedClasses
ownedClasses
Observer
Class
Class
observedClasses
27
Candidate Elements
1.1 Filter Candidate Elements For Every Port

Candidate Elements
1.2 Create Empty Pattern Instance
1.3 Call Bind Step For Every Ports Role
Pattern Instances
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
3.1 Check Pattern Instance For Bound Constrained
Roles
Pattern Instance
3.2 Check Constraint On Pattern Instance
Boolean
4. Connect Step
4.1 Get Element From Start Role
Pattern Instance
4.2 Traverse Connector From Start To End Roles
4.3 Call Bind Step for End Role
Pattern Instances
Write a Comment
User Comments (0)
About PowerShow.com