Design Patterns from Theory to Practice
Jing Dong (University of Texas, USA), Tu Peng (University of Texas, USA), Yongtao Sun (American Airlines, USA), Longji Tang (FedEx Dallas Tech Center, USA) and Yajing Zhao (University of Texas , USA)
Copyright: © 2009
Design patterns (Gamma, Helm, Johnson, & Vlissides, 1995) extract good solutions to standard problems in a particular context. Modern software industry has widely adopted design patterns to reuse best practices and improve the quality of software systems. Each design pattern describes a generic piece of design that can be instantiated in different applications. Multiple design patterns can be integrated to solve different design problems. To precisely and unambiguously describe a design pattern, formal specification methods are used. Each design pattern presents extensible design that can evolve after the pattern is applied. While design patterns have been applied in many large systems, pattern-related information is generally not available in source code or even the design model of a software system. Recovering pattern-related information and visualizing it in design diagrams can help to understand the original design decisions and tradeoffs. In this article, we concentrate on the issues related to design pattern instantiation, integration, formalization, evolution, visualization, and discovery. We also discuss the research work addressing these issues.
Design patterns are typically described informally for easy understanding. However, there are several drawbacks to the informal representation of design patterns. First, informal specifications may be ambiguous and imprecise. They may not be amendable to rigorous analysis. Second, formal specifications of design patterns also form the basis for the discovery of design patterns in large software systems. Third, design patterns are generic designs that need to be instantiated and perhaps integrated with other patterns when they are applied in software system designs. There can be errors and inconsistencies in the instantiation and integration processes by using informal specifications. Finding such errors or inconsistencies early at the design level is more efficient and effective than doing it at the implementation level. In addition, it is interesting to know whether some of these processes are commutative at the design level (Dong, Peng, & Qiu, 2007b).
The initial work on the formal specification of architecture and design patterns has been done in Alencar et al. (Alencar, Cowan, & Lucena, 1996). The composition of two design patterns based on a specification language (DisCo) has been discussed in Mikkonen (1998). A formal specification approach based on logics is presented in Eden and Hirshfeld (2001). Some graphical notations are also introduced to improve the readability of the specifications. The structural and behavioral aspects of design patterns in terms of responsibilities and rewards are formally specified in Soundarajan and Hallstrom (2004). Taibi and Ngo (2003) propose specifying the structural aspect of design patterns in the first order logic (FOL) and the behavioral aspect in the temporal logic of action (TLA). Formal specification of design patterns and their composition based on the language of temporal ordering specification (LOTOS) is proposed in Saeki (2000).
Key Terms in this Chapter
Design Patterns: Design patterns represent solutions to problems that arise when developing software within a particular context. Design patterns capture the static and dynamic structure and collaboration among key participants in software designs. Design patterns are generic design pieces that need to be instantiated before uses. The instantiation of a design pattern describes the process of applying generic design pieces into a system design. The integration of design patterns describes the process of composing multiple design patterns to solve a number of design problems. Design patterns can be integrated by overlapping common parts from different patterns or adding new relationships between parts from different patterns. The formalization of design patterns is to apply rigorous methods to specify design patterns or to verify their properties. These formal methods include logic-based and process-based methods. The evolution of a design pattern is a process to add or remove design elements to/from existing design pattern applications in a software system. It takes place when new requirements, platforms, technologies, or environments change and therefore software system need to be adapted to such change. The visualization of design pattern provides techniques and tools for explicitly visualizing the instances of design patterns applied in a large software system design. These visualization techniques and tools can help software designers for tracing, identifying, and checking design patterns in the software system design, and making right design decision of applying design patterns.