Pattern-based design evolution using graph transformation

https://doi.org/10.1016/j.jvlc.2007.07.004Get rights and content

Abstract

In recent years, design patterns gain more interest in software engineering communities for both software development and maintenance. As a template to solve a certain recurring problem, a design pattern documents successful experiences of software experts and gradually becomes the design guidelines of software development. Applying design patterns correctly can improve the efficiency of software design in terms of reusability and enhance maintainability during reverse engineering. Software can be evolved when developers modify their initial designs as requirements change. For instance, a developer may add/delete a set of design elements, such as classes and methods. Modifications on software artifacts can introduce conflicts and inconsistencies in the previously applied design patterns, which are difficult to find and time-consuming to correct. This paper presents a graph-transformation approach to pattern level design validation and evolution. Based on a well founded formalism, we validate a given design by a graph grammar parser and automatically evolve the design at pattern level using a graph-transformation system. Rules for potential pattern evolutions are predefined. The graph-transformation approach preserves the integrity and consistency of design patterns in the system when designs change. A prototype system is built and a case study on the Strategy pattern demonstrates the feasibility of pattern-based design validation and evolution using graph transformation techniques.

Introduction

Software systems become increasingly complicated and hard to maintain due to the massive information in the system and complex system structure. There has been an urgent need for an efficient and effective method to ease the tedious work at software development and maintenance stages. The emergence of object-oriented design patterns [1] makes software development more efficient in terms of reusability because design patterns document the successful experience of experts and provide solutions to certain reoccurring problems in particular contexts. Application of design patterns facilitates software development in that it allows software engineers to communicate and collaborate with each other efficiently. Well documented design patterns also assist the comprehension of legacy programs in reverse engineering.

In addition to efficient software development methodologies, software systems should always be adaptable to evolve upon modification requests from users or designers. This requires a system to be extensible and flexible since we cannot know all the requirements and build a perfect system at the beginning [2]. Arthur et al. [3] defined software evolution as “a continuous change from a lesser, simpler, or worse state to a higher or better state” for software system. To efficiently achieve such an evolution, modifications to a system generally start from the design level that hides massive programming information because the size of a design is typically much smaller and more manageable than that of codes.

Since Gamma et al. [1] first introduced the well recognized design patterns, intensive research has been carried out on the application of design patterns. The wide use of design patterns requires an effective mechanism to validate software designs and allow designers to make modifications on them as system requirements change. On one hand, it is necessary to guarantee that a design complies with the structural integrity of the design patterns that have been applied. On the other hand, any change on the design should not violate the structural properties of existing design patterns in the system, since a local modification may have a chain effect on the whole system. Manually checking the impact of a single modification, however, is a time-consuming and error-prone process. In general, design evolutions that happen at pattern level includes refactoring [4] and design pattern evolution [5]. Refactoring is to find the “bad smell” in the system and reconstruct it in order to achieve better efficiency with external behaviors preserved. Design pattern evolution is to refine a design pattern according to requirements changes while maintaining the pattern's properties. A design pattern normally includes changeable and stable parts. The changeable part of a design pattern can be potentially adapted to several different applications, while the stable part will remain. More specifically, pattern participants, e.g. classes and relationships, may be added to/removed from a particular design pattern without violating the pattern's structural properties and constraints. We defined such a process as a pattern level design evolution, in which pattern participants in a system design are modified but the fundamental properties of the design are preserved at the pattern level.

As a de facto standard to visually modeling software systems, UML provides a set of intuitive notations to represent design patterns and corresponding designs. The lack of formal semantics, however, prevents UML from automatic validation and evolution. Dong et al. [5] automated the design evolution process as XSLT transformations that can transform the UML model of a design pattern application into the evolved UML model of the pattern. Both the original and evolved UML models are represented in an XMI format to facilitate the transformations. To take advantage of the graphical characteristics UML diagrams, we explore a graph-transformation approach to pattern level design validation and evolution.

Graph transformation, which offers a computational paradigm of mathematical precision and visual specification [6], provides an intuitive yet formal means to interpret and manipulate visual languages. In general, graph transformation defines computation in a multi-dimensional fashion based on a set of rewriting rules, i.e. productions. Each production consists of two parts: a left graph and a right graph, the difference between which visually indicates the changes generated by a computation. By representing a design as a graph, the problem of design evolution is converted to graph evolution, which can be naturally realized through graph transformation: the left graph of a production indicates the pre-condition of an evolution and the right graph represents the post-condition after an evolution. Applying graph transformation to design evolution can guarantee that the design after evolution still observes the structural properties of its underlying patterns. A graph grammar system [7] extends a graph transformation system by (1) defining an initial graph and (2) classifying terminal and non-terminal objects. In this way, a graph grammar abstracts the essential structures shared by a set of graphs. Therefore, we formalize the structure of a design pattern into a graph grammar, and correspondingly validate the structural integrity of a design through a parsing process, i.e. a sequence of graph-transformations. Using visual representation to interpret software evolution and validation improves the expressiveness to human's understanding and communication.

In summary, this paper presents a graph-transformation framework for pattern level design validation and evolution, which is characterized by a syntax-oriented graphical design environment facilitated by an automatic design evolution tool. The graphical design environment can verify whether a design observes the structural integrity of a design pattern while the evolution tool can guarantee that a design after evolution is still consistent with the structural properties of its underlying patterns. Validation of a design is a parsing process on a graph representing the design. In order to improve the performance of the parsing process, each design pattern defines one key structure. We first locate the key structure in a design and then initiate a parsing process from the key structure. The key structure can narrow down the parser's searching scope and thus achieve a better performance. Based on the characteristics of GoF design patterns, we categorize pattern level design evolutions into five types [11] (e.g. independent evolution and packaged evolution), which are applicable to different design patterns. Each evolution style in a specific design pattern is defined through graph-transformation. When an evolution is carried out through graph transformation, the syntactic correctness of the evolved design is guaranteed with respect to a design pattern.

The contributions of this paper are threefold:

  • Formalizing design pattern structures using graphical representation.

  • Validating patterns in a design by the spatial graph grammars.

  • Realizing pattern-based design evolutions through graph-transformations.

The rest of the paper is organized as follows. Section 2 briefly introduces the Spatial Graph Grammar (SGG) [8] formalism and concepts of graph transformation. Section 3 explains the classification of design pattern evolutions. Section 4 presents the overview of our framework and investigates a graph-transformation approach to design pattern validation and evolution. Section 5 shows a prototype system and illustrates an example using the Strategy pattern. Section 6 reviews related work. Section 7 concludes this paper and discusses the future work.

Section snippets

The spatial graph grammar and graph-transformation

Graph grammars extend Chomsky's generative grammars into the domain of graphs. Different from string grammar expressing sentences in a sequence of characters, graph grammars are suitable for specifying information in a multidimensional fashion.

The SGG formalism [8] is a context-sensitive graph grammar formalism, which allows the left graph to have multiple nodes, and is expressive in specifying various types of graphs. The SGG formalism is expressed in a node-edge format as presented in Fig. 1.

Problem statement

Design patterns have been widely accepted as guidelines documenting the design of an object-oriented system since Gamma et al. [1] introduced the popular 23 design patterns. Each design pattern has a structure, behavior and semantic meaning. The structure indicates the structural relations among pattern elements; the behavior tells how pattern participants interact with each other and the semantic meaning defines the context of a problem addressed by the design pattern.

Therefore, each design

Overview

This section describes a general framework of our approach as shown in Fig. 6. Given a design, a graph-transformation-based design pattern evolution proceeds in three steps [12]:

Design representation: Using a graphical design environment, a designer can apply design patterns to a system design represented in UML class diagrams. Alternatively, design patterns can be retrieved from source codes using reverse engineering techniques. In either case, a design pattern expressed in a UML class diagram

A prototype system

This section shows a prototype system for an automated design pattern evolution based on SGG. At the system level, the graph-transformation approach described above is realized by four modules as shown in Fig. 13: node editor, production editor, graph-transformation engine and graphical editing tool in the node-edge format.

The node editor and production editor provide an easy-to-use user interface to define graph grammar and graph-transformation rules. A graph grammar formalizes the essential

Related work

Design pattern becomes popular in OO software research communities since Gamma et al. [1] proposed the catalog of design patterns. Research on design patterns mainly focuses on the techniques for pattern application, pattern recovery and pattern evolution. With the development of visual language applications [15], [16], [17], many research work have taken advantage of the formal foundation of visual languages, i.e. graph grammars and transformations, to address issues in the area of design

Conclusion and future work

Evolution of design patterns represented in UML diagrams is an important issue in software development. This paper has presented a graph-transformation approach to pattern-based design validation and evolution, which helps developers to validate their pattern level designs and allows further consistent modifications. We defined a set of productions for each design pattern based on its fundamental structure and behavior properties. We examined the characteristics of design pattern and summarized

Acknowledgments

The authors would like to thank the Guest Editors and the anonymous reviewers for their insightful and constructive comments that have helped us to significantly improve the paper.

References (26)

  • J. Rekers et al.

    Defining and parsing visual languages with layered graph grammars

    Journal of Visual Languages and Computing

    (1997)
  • G. Antoniol et al.

    Object-oriented design pattern recovery

    Journal of Systems and Software

    (2001)
  • E. Gamma et al.

    Design patterns: Elements of Reusable Object-oriented software

    (1995)
  • M. Ó Cinnéide, P. Nixon, Automated software evolution towards design patterns, in: Proceedings of the fourth...
  • L.J. Arthur

    Improving Software Quality: An Insider's Guide to TQM

    (1993)
  • J. Zhang et al.

    Generic and domain-specific model refactoring using a model transformation engine, Model-driven Software Development-Research and Practice in Software Engineering

    (2004)
  • J. Dong, S. Yang, Y. Sun, E. Wong, QVT based model transformation for design pattern evolutions, in: Proceedings of the...
  • D. Varró, A formal semantics of UML statecharts by model transition systems, in: Proceedings of ICGT 2002, Lecture...
  • G. Rozenberg (Ed.), Handbook of graph Grammars and Computing by Graph-Transformation: Foundations, vol. 1 (1), World...
  • J. Kong et al.

    Spatial graph grammars for graphical user interfaces

    ACM Transactions on Computer–Human Interaction (TOCHI)

    (2006)
  • D.Q. Zhang et al.

    A context-sensitive graph grammar formalism for the specification of visual languages

    Computer Journal

    (2001)
  • J. Dong, S. Yang, K. Zhang, A model transformation approach for design pattern evolutions, in: Proceedings of the 13th...
  • C. Zhao, J. Kong, K. Zhang, Design pattern evolution and verification using graph-transformation, in: Proceedings of...
  • Cited by (28)

    • Research on context of implicit context-sensitive graph grammars

      2019, Journal of Computer Languages
      Citation Excerpt :

      Visual representation is one of the inherent capabilities of graph grammars. The implicit formalisms, equipped with naive but efficient parsing algorithms, have hitherto found a wide range of applications, such as model management [23], multimedia layout adaptation [24,25], graphical user interface design and adaption [21], design pattern evolution [26], program behavior discovery and verification [27], web interface Adaptation [28], etc. Despite these effective applications in many graph-related fields, the implicit formalisms suffer two fundamental drawbacks.

    • A temporal graph grammar formalism

      2018, Journal of Visual Languages and Computing
      Citation Excerpt :

      Since the production of these graph grammars is quite simple, their expressive power is limited, which hinders the scope of their applications. On the other hand, with the increasing demands of intricate applications, context-sensitive graph grammars, such as CS-NCE (context-sensitive neighborhood controlled embedding graph grammar) [22–24], LGG(layered graph grammar) [25], RGG(reserved graph grammar) [7], SGG(spatial graph grammar) [26–28], EGG(edge based graph grammar) [29], have been appearing with more expressive power, which allow the left side of a production to be a graph instead of a node. In 1997, Rekers and Schürr [25] proposed a graph grammar formalism called LGG for specifying visual languages.

    • Design pattern-based model transformation supported by QVT

      2017, Journal of Systems and Software
      Citation Excerpt :

      Radermacher (1999) proposes PROGRES, a graph rewriting environment where design patterns are defined as graph rewriting rules and applied to an application model which has been analyzed for pattern applicability through graph queries. Zhao et al. (2007) proposed a graph transformation approach for evolving and validating pattern instances. In their work, pattern evolution is defined as a set of valid pattern instances described in the spatial graph grammar.

    • On applying machine learning techniques for design pattern detection

      2015, Journal of Systems and Software
      Citation Excerpt :

      Moreover, the table compares the tools according to some generic characteristics, i.e., supported languages, export format, and last update. Other recent DPD approaches exist in the literature, e.g., Pettersson and Lowe (2007), Zhao et al. (2007), Hu and Sartipi (2008), Bernardi and Lucca (2010), Issaoui et al. (2012), Alhusain et al. (2013), Rao and Gupta (2013), Yu et al. (2013), Alnusair et al. (2014), and Uchiyama et al. (2014), but to the best of our knowledge they have not been implemented as a tool, known to be available freely, commercially or under specific request. In this paper, we described a machine learning methodology applied to the problem of design pattern detection, implemented in a tool called MARPLE-DPD.

    • A language-independent and formal approach to pattern-based modelling with support for composition and analysis

      2010, Information and Software Technology
      Citation Excerpt :

      In [29], models are transformed to conform to patterns, after having exploited graph queries that detect needs for transformations. In [37] Spatial Graph Grammars provide a graph representation of GoF patterns, to transform object structure graphs so that they conform to patterns. Although declarative, the rules are based on a concrete presentation of patterns, and not on a meta-model characterisation.

    View all citing articles on Scopus
    View full text