Download presentation

Presentation is loading. Please wait.

Published byEvelyn Burton Modified over 3 years ago

1
22 July 2009 COMPSAC 2009 1 Tool Support for Design Pattern Recognition at Model Level Hong Zhu (1), Ian Bayley (1), Lijun Shan (2) and Richard Amphlett (1) (1) School of Technology, Oxford Brookes University, Oxford OX33 1HX, UK (2) Dept. of Computer Science, National University of Defense Technology, Changsha, China

2
22 July 2009 2 COMPSAC 2009 Outline Motivation and Related works Tool support to the application of DPs Formalisation of DPs Our Previous work Specification of DPs Semantics of UML models The proposed approach Bridge the gaps The tool LAMBDES-DP Experiments Conclusion and future work

3
22 July 2009 3 COMPSAC 2009 Motivation Design Patterns (DPs) Reusable solutions to commonly occurring design problems Represented in Alexandrian form Synopsis, Context, Forces, Solution, Consequences, Implementation, Examples, Related patterns Proper use can improve software quality and development productivity Reduce ambiguity Automated tool support Explained in informal English Clarified with illustrative diagrams Specific code examples

4
22 July 2009 4 COMPSAC 2009 Existing works 1: Tool support Instantiation of patterns widely available in modelling tools Pattern recognition tools Code level: More than a dozen reported in the literature (Dong, Zhao and Peng, SERP 2007) Well-known examples: HEDGEHOG (Blewitt, Bundy and Stark, ASE 2005) FUJABA (Niere, et al. ICSE 2002) PINOT (Shi and Olsson, ASE 2006) Design/Model level (Kim and Lu, ICECCS06): Translate RBML and UML into Prolog (Kim and Shen, SAC07, SQJ 2008): RBMLCC Plug-in to IBM Rational Rose Pattern specified by metamodel in RBML Apply it to 7 of the 23 GoF patterns Class diagram only Low level of abstraction Late in development process Hard to improve precision and recall rate

5
22 July 2009 5 COMPSAC 2009 Existing works 2: Formalisation of DPs Le Guennec et al. (UML 2000): the extension of the UML meta- model and OCL Eden (2001): the graphical language LePUS Mapelsden et al. (CRPIT 02): Design Pattern Modeling Language Taibi (2003, 2006) and Mikkonen (ICSE98): the use of predicate logic and temporal logic Kim, France, Ghosh, and Song (COMPSAC 2003): Role-based metamodelling language RBML Bayley and Zhu (SEFM07, COMPSAC08, QSIC08): first order logic And many other works, e.g. Lano et al. (1996), Lauder and Kent (1998), Mak, et al. (ICSE04), Zdun and Avgeriou (OOPLSA05), etc.

6
22 July 2009 6 COMPSAC 2009 Previous work 1: Specification of DPs Formal meta-modelling in first order logic (Bayley and Zhu 2007, 2008) The abstract syntax of UML diagrams specified in GEBNF (Graphically Extended BNF). A first-order predicate logic (FOL) language systematically derived from the abstract syntax definition Specifying design patterns in the FOL as predicate on UML diagrams and pattern instantiation is predicate satisfaction. Advantages: Expressiveness: Both structural feature and behavioural features in the same FOL Variants of patterns can be specified All 23 GoF patterns are specified Readability: More readable than its rivals Facilitate reasoning, operations and transformations of DPs to formally prove their properties and relationships to compose patterns

7
22 July 2009 7 COMPSAC 2009 Example: Template Method pattern =

8
22 July 2009 8 COMPSAC 2009 Previous work 2: Semantics of UML models Descriptive semantics of modelling language (Shan and Zhu, 2008) The formal semantics of UML is resolved into two aspects: descriptive semantics: defines which systems are instances of a model. e.g. the system consists of two classes A and B, and A is a subclass of B. functional semantics: defines the basic modeling concepts, e.g. If class X is a subclass of Y, then all instances of X are also instances of Y. It describes the system without referring to what is meant by class and subclass. It defines the notion of class and subclass. Perhaps uses axioms on the dynamic behaviour of systems.

9
22 July 2009 9 COMPSAC 2009 Translation of models into First Order Logic Signature mapping: rules to derive symbols of FOL from the metamodel Axiom mapping: rules to derive statements in the FOL from the metamodel that must be true for all valid models Translation mapping: rules to translate a graphical model into predicates in FOL that it is true if and only if a system is an instance of the model Hypothesis mapping: rules that selected by the user to be applied in order to characterise the context in which the model is used

10
22 July 2009 10 COMPSAC 2009 Example: The following is a subset of the predicates generated from the diagram

11
22 July 2009 11 COMPSAC 2009 Bridging the Gap Differences between the FOL for DP spec and the FOL for UML semantics Syntactic difference Semantic difference Predicates in a DP specification are evaluated on UML models Predicates in the descriptive semantics of UML models are evaluated on software systems DP specification is translated into the syntax of FOL for descriptive semantics

12
22 July 2009 12 COMPSAC 2009 Example: The specification of Template Method can be translated into:

13
22 July 2009 13 COMPSAC 2009 P is a pattern. Spec(P) is the formal specification of P. The descriptive semantics of model m. System s is an instance of model m. System s satisfies the specification. Recognition of a pattern at design level becomes a logic inference problem.

14
22 July 2009 14 COMPSAC 2009 The Tool LAMBDES-DP

15
22 July 2009 15 COMPSAC 2009 Experiments: 1. Use StarUML to produce design instances as UML diagrams and export them as XMI representations. 2. Use LAMBDES to convert these XMI representations to FOL; 3. Use LAMBDES to check these FOL representations for consistency errors, revising them until there are no more errors; 4. For each pattern, use LAMBDES-DP to determine if the model conforms to (i.e. implies the specification of) the pattern. Three possible outcomes: Proof Found, meaning definitely yes, Completion Found, meaning definitely no, and Time Out, meaning that no proof was found in the maximum time limit that SPASS allows, which is 990 seconds.

16
22 July 2009 16 COMPSAC 2009 Subjects of the experiments Patterns: 23 Patterns in GoF book Design Instances: Two sets of design instances were produced manually from the diagrams in the GoF book. Set 1 (Class Only): contains a class diagram for each of the 23 patterns in the book. Set 2 (Class + Seq): contains class and sequence diagrams for the only 6 patterns in the book that contain both.

17
22 July 2009 17 COMPSAC 2009 Overview of the Design Instances: ClassOnly Set

18
22 July 2009 18 COMPSAC 2009 Overview of the Design Instances: Class+Seq Set

19
22 July 2009 19 COMPSAC 2009 Experiment Results ClassOnlyClass+Seq Recall (False negative error rate) 0% Precision (False positive error rate) < 22%0% Conclusion: Recognition of patterns at design level can be accurate with good precision and recall rate; Behavioural feature is crucial for accurate specification and hence the recognition of patterns, as we have argued in (Bayley and Zhu, COMPSAC 2008);

20
22 July 2009 20 COMPSAC 2009 Future work Improvement of the efficiency of LAMBDES-DP SPASS cannot handle the inference of large logic systems (when it has more than 1000 formulas, which is equivalent to models that have more than 10 elements.) Enhance LAMBDES-DP functionality Pattern composition Pattern directed refactoring at design level Reasoning about patterns Experiment with industrial real systems Integration with code level tools Some tools extract information from code and represent the extracted information in the form of first order logic predicates

21
22 July 2009 21 COMPSAC 2009 References I. Bayley and H. Zhu. Formalising design patterns in predicate logic. In Proc. of SEFM07, pp 25–36. I. Bayley and H. Zhu. On the composition of design patterns. Proc. of QSIC08, pp27–36. I. Bayley and H. Zhu. Specifying behavioural features of design patterns in first order logic. Proc. of COMPSAC08, pp203–210. L. Shan and H. Zhu. A formal descriptive semantics of UML. Proc. of ICFEM09, pp375–396. L. Shan and H. Zhu, Semantics of Metamodels in UML, Proc. of TASE09. (In press)

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google