1 / 21

Tool Support for Design Pattern Recognition at Model Level

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

Download Presentation

Tool Support for Design Pattern Recognition at Model Level

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. COMPSAC 2009 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. 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 COMPSAC 2009

  3. Motivation Explained in informal English • 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 Clarified with illustrative diagrams Specific code examples COMPSAC 2009

  4. 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, ICECCS’06): Translate RBML and UML into Prolog • (Kim and Shen, SAC’07, 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 COMPSAC 2009

  5. 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 (ICSE’98): the use of predicate logic and temporal logic • Kim, France, Ghosh, and Song (COMPSAC 2003): Role-based metamodelling language RBML • Bayley and Zhu (SEFM’07, COMPSAC’08, QSIC’08): first order logic • And many other works, e.g. Lano et al. (1996), Lauder and Kent (1998), Mak, et al. (ICSE’04), Zdun and Avgeriou (OOPLSA’05), etc. COMPSAC 2009

  6. 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 COMPSAC 2009

  7. = Example: Template Method pattern COMPSAC 2009

  8. 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. Perhaps uses axioms on the dynamic behaviour of systems. It defines the notion of class and subclass. COMPSAC 2009

  9. 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 COMPSAC 2009

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

  11. 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 COMPSAC 2009

  12. Example: • The specification of Template Method can be translated into: COMPSAC 2009

  13. 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. COMPSAC 2009

  14. The Tool LAMBDES-DP COMPSAC 2009

  15. 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. COMPSAC 2009

  16. 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. COMPSAC 2009

  17. Overview of the Design Instances: ClassOnly Set COMPSAC 2009

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

  19. Experiment Results 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); COMPSAC 2009

  20. 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 COMPSAC 2009

  21. References • I. Bayley and H. Zhu. Formalising design patterns in predicate logic. In Proc. of SEFM’07, pp 25–36. • I. Bayley and H. Zhu. On the composition of design patterns. Proc. of QSIC’08, pp27–36. • I. Bayley and H. Zhu. Specifying behavioural features of design patterns in first order logic. Proc. of COMPSAC’08, pp203–210. • L. Shan and H. Zhu. A formal descriptive semantics of UML. Proc. of ICFEM’09, pp375–396. • L. Shan and H. Zhu, Semantics of Metamodels in UML, Proc. of  TASE’09. (In press) COMPSAC 2009

More Related