Download presentation
Presentation is loading. Please wait.
Published byFranklin Ellis Modified over 8 years ago
1
A UML-Based Pattern Specification Technique Presented by Chin-Yi Tsai IEEE TRANSACTION ON SOFTWARE ENGINEERING, VOL. 30, NO. 3, MARCH 2004 Robert B. France, Member, IEEE Computer Society, Dae-Kyoo Kim, Student Member, IEEE, Sudipto Ghosh, Member, IEEE Computer Society, and Eunjee Song, Student Member, IEEE
2
2 Outline Introduction Introduction Background Background Specifying Pattern Solutions Specifying Pattern Solutions Specifying Visitor Pattern Solutions Specifying Visitor Pattern Solutions An Analysis of Early Experience An Analysis of Early Experience Related Work Related Work Conclusion and Further Work Conclusion and Further Work
3
3 Introduction A design pattern describes a family of solutions for a class of recurring design problems. A design pattern describes a family of solutions for a class of recurring design problems. Pattern specification languages that are based on familiar software modeling concepts are more likely to be usable by software developers. Pattern specification languages that are based on familiar software modeling concepts are more likely to be usable by software developers. Pattern specification expressed in the UML: Pattern specification expressed in the UML: Standard for object-oriented modeling Standard for object-oriented modeling MDA that supports the use of models as primary artifacts of development MDA that supports the use of models as primary artifacts of development
4
4 Introduction (cont ’ d) The pattern specification created by thetechnique are metamodels that characterize UML design models of pattern solution. The pattern specification created by thetechnique are metamodels that characterize UML design models of pattern solution. A pattern ’ s metamodel is obtained by specializing the UML metamodel. A pattern ’ s metamodel is obtained by specializing the UML metamodel.
5
5 Background A pattern solution is described form two perspectives: A pattern solution is described form two perspectives: The structural view The structural view The interaction view The interaction view
6
6 Specializing the UML Metamodel UML four-layer architecture UML four-layer architecture The UML metamodel The UML metamodel Class diagram Class diagram Well-formedness rules Well-formedness rules The UML metamodel can be specialized to produce a restricted form of the UML metamodel that defines a proper subset of valid UML model. The UML metamodel can be specialized to produce a restricted form of the UML metamodel that defines a proper subset of valid UML model.
7
7 Specializing the UML Metamodel (cont ’ d) Specializing the UML metamode to obtain a pattern specification: Specializing the UML metamode to obtain a pattern specification: Specializing the abstract syntax by subtyping UML metamodel classes and by making the well-formedness rules more restrictive Specializing the abstract syntax by subtyping UML metamodel classes and by making the well-formedness rules more restrictive Defining parameterized OCL constraints Defining parameterized OCL constraints
8
8 Specifying Pattern Solutions A pattern specification contains a Structural Pattern Specification (SPS) and a set of Interaction Pattern Specifications (IPSs). A pattern specification contains a Structural Pattern Specification (SPS) and a set of Interaction Pattern Specifications (IPSs). A UML model conforms to a pattern specification if its class diagram conforms to the SPS and the interactions described by sequence diagrams conform to the IPSs. A UML model conforms to a pattern specification if its class diagram conforms to the SPS and the interactions described by sequence diagrams conform to the IPSs.
9
9 Structural Pattern Specifications A SPS defines the part of the pattern metamodel that characterizes class diagram views of pattern solutions. A SPS defines the part of the pattern metamodel that characterizes class diagram views of pattern solutions. An SPS consists of a structure of pattern roles (henceforth referred to as roles), where a role specifies properties that a UML model element must have if it is to be part of a pattern solution model. An SPS consists of a structure of pattern roles (henceforth referred to as roles), where a role specifies properties that a UML model element must have if it is to be part of a pattern solution model. The metamodel class is called the base of the role. The metamodel class is called the base of the role. A role with a base B specifies a subset of instances of the UML metamodel class B. A role with a base B specifies a subset of instances of the UML metamodel class B.
10
10 Structural Pattern Specifications (cont ’ d) A UML model element conforms to (or plays) a role if it satisfies the properties defined in the role, that is, the element is an instance of the subtype defined by the role. A UML model element conforms to (or plays) a role if it satisfies the properties defined in the role, that is, the element is an instance of the subtype defined by the role. A role in an SPS can be classified as a classifier or a relationship role. A role in an SPS can be classified as a classifier or a relationship role. A role that has the base Classifier or a base that is a subtype of Classifier (e.g., Class, Interface) is a classifier role. A role that has the base Classifier or a base that is a subtype of Classifier (e.g., Class, Interface) is a classifier role. A relationship role is any role that has the base Relationship or a base that is a subtype of Relationship (e.g., Association, Generalization). A relationship role is any role that has the base Relationship or a base that is a subtype of Relationship (e.g., Association, Generalization).
11
11 The SPS Notation A classifier role is represented by a syntactic variant of the UML class symbol. A classifier role is represented by a syntactic variant of the UML class symbol. Structure of a classifier role. Structure of a classifier role. A relationship role is represented by a syntactic variant of the UML association symbol. A relationship role is represented by a syntactic variant of the UML association symbol. Well-formedness rules that cannot be expressed in an SPS's role structure are expressed in the OCL (Object Constraint Language). Well-formedness rules that cannot be expressed in an SPS's role structure are expressed in the OCL (Object Constraint Language).
12
12 An SPS Example A partial views of an SPS and its metamodel A partial views of an SPS and its metamodel context Subject inv : self:isAbstract = false context Sub inv : self:lowerBound() = 1 self:upperBound() = 1 context Obs inv : self:lowerBound() = 0
13
13 Establishing Structural Conformance to an SPS A class diagram structurally conforms to an SPS, with respect to a binding of model elements to roles, if it satisfies: A class diagram structurally conforms to an SPS, with respect to a binding of model elements to roles, if it satisfies: the structural constraints specified by the SPS role structure the structural constraints specified by the SPS role structure the metamodel-level constraints the metamodel-level constraints
14
14 Establishing Structural Conformance to an SPS (cont ’ d) The following activities are carried out when establishing that a class diagram structurally conforms to an SPS: The following activities are carried out when establishing that a class diagram structurally conforms to an SPS: Bind models elements to roles Bind models elements to roles Check compliance with classifier role realization multiplicities Check compliance with classifier role realization multiplicities Establish structural conformance of classifiers to their bound roles Establish structural conformance of classifiers to their bound roles Establish conformance of relationships to their bound relationship roles Establish conformance of relationships to their bound relationship roles
15
15 Establishing Structural Conformance to an SPS (cont ’ d) An SPS and a structurally conforming class diagram. An SPS and a structurally conforming class diagram.
16
16 Establishing Structural Conformance to an SPS (cont ’ d) A partial SPS for a variant of the Observer pattern and a conforming class diagram. A partial SPS for a variant of the Observer pattern and a conforming class diagram.
17
17 Specifying Semantic Pattern Properties in an SPS The role structure and metamodel-level constraints of an SPS determine the syntactic structure of conforming class diagrams. The role structure and metamodel-level constraints of an SPS determine the syntactic structure of conforming class diagrams. An operation template for the Attach BehavioralFeature role is given below: An operation template for the Attach BehavioralFeature role is given below: context|Subject :: |Attach(|obsv : |Observer) pre : true post : self:|Obs = self:|Obs@pre including(|obsv)
18
18 Specifying Semantic Pattern Properties in an SPS (cont ’ d) The Subject role is also associated with the following BehavioralFeature roles: The Subject role is also associated with the following BehavioralFeature roles: Detach Detach specifies behaviors that remove observers from subjects specifies behaviors that remove observers from subjects SetState SetState specifies behaviors that set the subject state specifies behaviors that set the subject state Notify Notify specifies behaviors that notify observers whenever a change in the subject state occurs specifies behaviors that notify observers whenever a change in the subject state occurs GetState GetState specifies behaviors that return the subject state specifies behaviors that return the subject state
19
19 Specifying Semantic Pattern Properties in an SPS (cont ’ d) context |Subject :: |Detach(|obsv : |Observer) pre : self.|Obs includes(|obsv) post : self.jObs = self.|Obs@pre excluding(|obsv) context jSubject :: |GetState() : |SubjStateType pre : true post : result = |SubjectState context |Subject :: |SetState(|newState : |SubjStateType) pre : true post : |SubjectState = |newState context |Observer :: |Update(|subj : |Subject) pre : true post : |ObserverState = |Function(|subj.|SubjectState)
20
20 Specifying Semantic Pattern Properties in an SPS (cont ’ d) Constraint templates can also be used to specify invariant properties in a UML model. Constraint templates can also be used to specify invariant properties in a UML model. These templates are referred to as property templates. These templates are referred to as property templates. context |Subject |Obs --> forAll(|ObserverState = |Function(|SubjectState)
21
21 Establishing Full Conformance to an SPS A class diagram fully conforms to an SPS, with respect to a binding of model elements to roles, if A class diagram fully conforms to an SPS, with respect to a binding of model elements to roles, if it structurally conforms to the SPS it structurally conforms to the SPS the semantic properties expressed by constraints in the class diagrams (e.g., operation specifications and class invariants) conform to the constraint templates in the SPS the semantic properties expressed by constraints in the class diagrams (e.g., operation specifications and class invariants) conform to the constraint templates in the SPS Establishing that the semantic properties expressed in a class diagram conform to constraint templates in an SPS involves Establishing that the semantic properties expressed in a class diagram conform to constraint templates in an SPS involves instantiating the constraint templates using the role bindings instantiating the constraint templates using the role bindings establishing that the constraints given in the class diagram refine the instantiations of the constraint templates establishing that the constraints given in the class diagram refine the instantiations of the constraint templates
22
22 Establishing Full Conformance to an SPS (cont ’ d) Establishing that an operation specification conforms to an operation template involves proving that the operation specification refines the operation template instantiation. Establishing that an operation specification conforms to an operation template involves proving that the operation specification refines the operation template instantiation. Given an operation Op with pre and postconditions Given an operation Op with pre and postconditions context Op(...) : pre: preR; post: postR context Op(...) : pre: preR; post: postR and an instantiated operation template for a feature role ROp context ROp(...) : pre: preM; post: postM, context ROp(...) : pre: preM; post: postM, Op is said to fully conform to ROp if preM => preR preM => preR (preM and postR) => postM (preM and postR) => postM
23
23 Interaction Pattern Specifications (IPSs) An Interaction Pattern Specification (IPS) describes a pattern of interactions and is defined in terms of roles defined in an SPS. An Interaction Pattern Specification (IPS) describes a pattern of interactions and is defined in terms of roles defined in an SPS. The SPS roles are used to specify participants in an interaction pattern. The SPS roles are used to specify participants in an interaction pattern.
24
24 Interaction Pattern Specifications (IPSs) (cont ’ d) An IPS for an Observer pattern and a partial view of its specialized UML metamodel. An IPS for an Observer pattern and a partial view of its specialized UML metamodel.
25
25 Interaction Pattern Specifications (IPSs) (cont ’ d) An IPS consists of an interaction role that defines a specialization of the UML metamodel class Interaction. An IPS consists of an interaction role that defines a specialization of the UML metamodel class Interaction. An interaction role is a structure of lifeline and message roles. An interaction role is a structure of lifeline and message roles. A message role is associated with a BehavioralFeature role: A conforming message specifies a call to an operation that conforms to the BehavioralFeature role. A message role is associated with a BehavioralFeature role: A conforming message specifies a call to an operation that conforms to the BehavioralFeature role.
26
26 Interaction Pattern Specifications (IPSs) (cont ’ d) A sequence diagram that conforms to the Observer IPS A sequence diagram that conforms to the Observer IPS
27
27 Specifying Visitor Pattern Solutions Visitor design pattern solution class diagram Visitor design pattern solution class diagram
28
28 Specifying Visitor Pattern Solutions (cont ’ d) Visitor design pattern solution sequence diagram Visitor design pattern solution sequence diagram
29
29 A Visitor SPS The SPS contains two role hierarchies The SPS contains two role hierarchies The Visitor The Visitor The Element The Element context | AbstractVisitor inv : self:oclIsTypeOf(Interface) or (self:oclIsTypeOf(class) and self:isAbstract = true) context | AbstractVisitor inv : self:oclIsTypeOf(Class) and self:isAbstract = false context | Obj inv : self:lowerBound() = 0 and self:upperBound() = 1 context | Elem inv : self:lowerBound() = 1
30
30 A Visitor SPS (cont ’ d) A more complex Visitor conformant class diagram A more complex Visitor conformant class diagram
31
31 An IPS for the Visitor Pattern A Visitor IPS A Visitor IPS
32
32 A Composite Part Structure
33
33 A Conforming Visitor Sequence Diagram
34
34 An Analysis of Early Experience The goal of author ’ s work is to create practical pattern specification that supports the use of patterns. The goal of author ’ s work is to create practical pattern specification that supports the use of patterns. To achieve this goal To achieve this goal The advantage of using UML as syntactic base for the pattern specification The advantage of using UML as syntactic base for the pattern specification Prototype tool for crating pattern specification on the top of the Rational Rose tool Prototype tool for crating pattern specification on the top of the Rational Rose tool
35
35 An Analysis of Early Experience (cont ’ d) Constraint templates Constraint templates The pattern specification language has been used by graduate students to develop specification of design pattern. The pattern specification language has been used by graduate students to develop specification of design pattern. Create specification for patterns that did not involve the use of recursion in the interaction diagram Create specification for patterns that did not involve the use of recursion in the interaction diagram The use of the UML notation to express roles helped in communicating the concepts The use of the UML notation to express roles helped in communicating the concepts Modeled by state machines and activity diagram Modeled by state machines and activity diagram
36
36 Related Work Specifying design patterns Specifying design patterns Formal specification techniques Formal specification techniques Using graphical constraint diagram Using graphical constraint diagram In terms of three layers of models: role-model, type-model, and class-model In terms of three layers of models: role-model, type-model, and class-model UML metamodeling appproach UML metamodeling appproach
37
37 Conclusion and Further Work The pattern specification technique described in this paper can be used as a base for tools that support creation and evolution of patterns, and rigorous application of design patterns to UML models. The pattern specification technique described in this paper can be used as a base for tools that support creation and evolution of patterns, and rigorous application of design patterns to UML models. Specifying pattern solutions at the UML metamodel level allows tool developers to build support for creating patterns and for checking conformance to pattern specifications. Specifying pattern solutions at the UML metamodel level allows tool developers to build support for creating patterns and for checking conformance to pattern specifications.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.