A Metric of the Relative Abstraction Level of Software Patterns

Similar documents
A Metric for Measuring the Abstraction Level of Design Patterns

WS01/02 - Design Pattern and Software Architecture

CS/CE 2336 Computer Science II

Design Patterns. An introduction

Design Patterns. Observations. Electrical Engineering Patterns. Mechanical Engineering Patterns

Slide 1. Design Patterns. Prof. Mirco Tribastone, Ph.D

Using Design Patterns in Java Application Development

Ingegneria del Software Corso di Laurea in Informatica per il Management. Design Patterns part 1

Design Pattern. CMPSC 487 Lecture 10 Topics: Design Patterns: Elements of Reusable Object-Oriented Software (Gamma, et al.)

Coordination Patterns

SYLLABUS CHAPTER - 1 [SOFTWARE REUSE SUCCESS FACTORS] Reuse Driven Software Engineering is a Business

Design patterns generic models

MVC. Model-View-Controller. Design Patterns. Certain programs reuse the same basic structure or set of ideas

Patterns for Decoupling

Idioms and Design Patterns. Martin Skogevall IDE, Mälardalen University

Lectures 24 and 25 Introduction to Architectural Styles and Design Patterns

Design Patterns. Manuel Mastrofini. Systems Engineering and Web Services. University of Rome Tor Vergata June 2011

Software Design Patterns. Background 1. Background 2. Jonathan I. Maletic, Ph.D.

Design Patterns. Hausi A. Müller University of Victoria. Software Architecture Course Spring 2000

Produced by. Design Patterns. MSc in Communications Software. Eamonn de Leastar

Trusted Components. Reuse, Contracts and Patterns. Prof. Dr. Bertrand Meyer Dr. Karine Arnout

SDC Design patterns GoF

Ingegneria del Software Corso di Laurea in Informatica per il Management. Design Patterns part 1

Patterns. Erich Gamma Richard Helm Ralph Johnson John Vlissides

Object Oriented Methods with UML. Introduction to Design Patterns- Lecture 8

DESIGN PATTERN - INTERVIEW QUESTIONS

UNIT I Introduction to Design Patterns

An Introduction to Patterns

What is Design Patterns?

Design Patterns: Structural and Behavioural

Applying the Observer Design Pattern

APPLYING DESIGN PATTERNS TO SCA IMPLEMENTATIONS

Introduction to Software Engineering: Object Design I Reuse & Patterns

Design Patterns. Gunnar Gotshalks A4-1

Socket attaches to a Ratchet. 2) Bridge Decouple an abstraction from its implementation so that the two can vary independently.

Plan. Design principles: laughing in the face of change. What kind of change? What are we trying to achieve?

CSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich

Design Pattern What is a Design Pattern? Design Pattern Elements. Almas Ansari Page 1

Foundations of Software Engineering Design Patterns -- Introduction

Modellistica Medica. Maria Grazia Pia, INFN Genova. Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico

Tuesday, October 4. Announcements

Applying the Decorator Design Pattern

Applying Design Patterns to SCA Implementations

A Rapid Overview of UML

CS560. Lecture: Design Patterns II Includes slides by E. Gamma et al., 1995

Object-oriented Software Design Patterns

Keywords: Abstract Factory, Singleton, Factory Method, Prototype, Builder, Composite, Flyweight, Decorator.

3 Product Management Anti-Patterns by Thomas Schranz

UNIT I Introduction to Design Patterns

6.3 Patterns. Definition: Design Patterns

LECTURE NOTES ON DESIGN PATTERNS MCA III YEAR, V SEMESTER (JNTUA-R09)

PatternRank: A Software-Pattern Search System Based on Mutual Reference Importance

Object-Oriented Software Development Goal and Scope

A Novel Approach to Automated Design Pattern Detection

EPL 603 TOPICS IN SOFTWARE ENGINEERING. Lab 6: Design Patterns

Applying Design Patterns to accelerate development of reusable, configurable and portable UVCs. Accellera Systems Initiative 1

CSCI Object Oriented Design: Frameworks and Design Patterns George Blankenship. Frameworks and Design George Blankenship 1

Introduction and History

An Introduction to Patterns

Extensibility Design Patterns From The Initial Stage of Application Life-Cycle

Towards Better Support for Pattern-Oriented Software Development

Overview of Patterns: Introduction

Introduction to Design Patterns

Applying the Factory Method Design Pattern

CS251 Software Engineering Lectures 18: Intro to DP

Introduction to Design Patterns

Produced by. Design Patterns. MSc in Computer Science. Eamonn de Leastar

Transparent Remote Access

Software Design COSC 4353/6353 D R. R A J S I N G H

Object Oriented Paradigm

The Design Patterns Matrix From Analysis to Implementation

Software Engineering I (02161)

Design patterns. Valentina Presutti courtesy of Paolo Ciancarini

CHAPTER 6: CREATIONAL DESIGN PATTERNS

Lecture 4: Observer Pattern, Event Library and Componentization

Lecture 19: Introduction to Design Patterns

What is Design Patterns?

Mining Relationships Between the Participants of Architectural Patterns

Object-Oriented Design

Design pa*erns. Based on slides by Glenn D. Blank

CS 349 / SE 382 Design Patterns. Professor Michael Terry January 21, 2009

THE DESIGN PATTERNS JAVA COMPANION JAMES W. COOPER. Copyright 1998, by James W. Cooper

CSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich

Reuse at Design Level: Design Patterns

Review Software Engineering October, 7, Adrian Iftene

Modellistica Medica. Maria Grazia Pia, INFN Genova. Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico

Design patterns. Jef De Smedt Beta VZW

Object-Oriented Design

Design Patterns. "Gang of Four"* Design Patterns. "Gang of Four" Design Patterns. Design Pattern. CS 247: Software Engineering Principles

CSCI 253. Overview. The Elements of a Design Pattern. George Blankenship 1. Object Oriented Design: Template Method Pattern. George Blankenship

Design Patterns V Structural Design Patterns, 2

Classifying Relationships Between Object-Oriented Design Patterns

Distributed Proxy: A Design Pattern for Distributed Object Communication

CS 247: Software Engineering Principles. Design Patterns

INSTITUTE OF AERONAUTICAL ENGINEERING

The GoF Design Patterns Reference

Application Architectures, Design Patterns

Information systems modelling UML and service description languages

A Reconnaissance on Design Patterns

Lecture 20: Design Patterns II

Transcription:

A Metric of the Relative Abstraction Level of Software Patterns Atsuto Kubo 1, Hironori Washizaki 2, and Yoshiaki Fukazawa 1 1 Department of Computer Science, Waseda University, 3-4-1 Okubo, Shinjuku-ku, Tokyo 169-8555, Japan a.kubo@fuka.info.waseda.ac.jp, fukazawa@waseda.jp 2 National Institute of Informatics, 2-1-2 Hitotsubashi, Chiyoda-ku, Tokyo 101-8430, Japan washizaki@nii.ac.jp Abstract. The abstraction level of the problem treated by a design pattern has wide variety, from architecture to near implementation. However, there is no objective metric indicating the abstraction level of the problems addressed by patterns. Thus, it is difficult to understand the abstraction level of each pattern and to position a new pattern. In this paper, a metric is proposed. It indicates the relative abstraction level of a pattern s problem. We propose a metric obtained from inter-pattern relationships. We also propose a visualization method for the metric. Using such metrics, we aim to help developers easily understand the abstraction level of each pattern, therefore, to better decide about its usefulness for the problem at hand. 1 Introduction A software pattern is a proven solution to a recurring problem that appears in the context of software development [1]. Describing the knowledge of experienced developers promotes sharing and reusing their knowledge. Many authors have published many patterns, and most of the patterns have relationships to other patterns. A pattern collection is a set of patterns that may or may not be related to each other. From architectural designing to implementation, developers break the system down gradually into components. Initially, the system is independent from details in design and implementation. Near the end of development, components depend on a concrete language and environment. We assume the abstraction level of the system as the granularity of the system s components. When the system can be divided into some subsystems, the system has a higher abstraction level than the each subsystems. Similarly, when the subsystem can be divided into some packages, the subsystem has a higher abstraction level than the each packages. The abstraction level of the pattern is defined similarly; the abstraction level of the pattern is the granularity of components that the pattern mainly deals. Architectural patterns deal the system and its subsystems. Most of design patterns deal some classes or some functions.

Generally, software patterns are classified into three classes, such as Architectural Patterns, Design Patterns, and Idioms. The three classes correspond to the development phases, and the development phases correspond to the system s abstraction level. Therefore, there are three abstraction levels of patterns that deals the components of the system. Developers often choose patterns according to the abstraction level. In the architectural design phase, developers should not be aware of idioms, and in the implementation phase, developers should not be aware of architectural patterns. The patterns mismatching current development phase may make developers confused. For example, in architectural design, developers shouldn t discuss the Singleton pattern [2], because the problem dealt by the Singleton pattern is too finely-granular to discuss in the architectural design phase. Choosing appropriate patterns from the pattern collection gets more difficult according to the size of pattern collection. The abstraction levels are used to help choosing appropriate patterns. However, the three abstraction level above-mentioned has some ambiguity for following reasons. First, the abstraction levels of patterns are different even if they belong to the same pattern catalog. For example, Gang of Four (GoF) s Interpreter pattern [2] has coarsegrained substructures, such as a tree structure provided by the Composite [2] pattern and abstraction of retrieving provided by the Iterator [2] pattern. Conversely, the Singleton [2] pattern fine-grained substructures, such as plain object-oriented classes. Second, developers cannot clearly classify some patterns into architectural patterns, design patterns, or idioms. For example, the Model-View-Controller (MVC) pattern [3] [1] is near design patterns because it assumes some fine-grained substructure, such as a callback mechanism provided the Observer pattern [2]. From above reasons, the metric of the abstraction levels of patterns are needed. In this paper, we propose a metric that indicates the relative abstraction level of each pattern in a set of patterns. The proposed metric is based on the asymmetric relationships between two patterns. The proposed metric provides positional information to pattern maps. The patterns in pattern maps can be positioned using the values of the proposed metrics. Section 2 provides the detail of the proposed metric. In Section 3, we perform two visual demonstration of the proposed metric. Section 4 discusses several related works, and Section 5 shows the conclusion and future works. 2 A metric measuring the abstraction level of design patterns Most of patterns have one or more inter-pattern relationships. Authors of patterns often describe these relationships in the Related Patterns sections. Table 1 lists some examples of inter-pattern relationships. In this metric, we use only the asymmetric inter-pattern relationships, such as Uses, Refines, and Provides context, shown on Table 1 for following reasons.

Table 1. A list of inter-pattern relationships Kind of relationship Description Asymmetric Similar to [4, 5] Pattern X is similar to Pattern Y. No Uses[4 6] Pattern X uses another pattern Y in its solution. Yes Refines [1, 5], Specific [6] Pattern Y provides a more specific solution Yes than pattern X. Combinable [1] Pattern X and Pattern Y can be combined. No Variation [1] Pattern Y is pattern X with some No changes to Y s solution. Provides context [6] When pattern X is implemented, pattern Y can be also implemented. However, Y is not necessary for X to work. Yes On the Uses relationships, a pattern uses another pattern as the part of it. The structure or behavior provided by used patterns are the subcomponent of using patterns. For example, the structure of the Interpreter pattern s syntax tree can be designed using the Composite pattern. That is a Uses relationship. Some inter-pattern relationships exist across different pattern catalogs. As another example, the MVC pattern uses the Observer pattern. On the Refines relationships, a pattern is a refined version of another pattern according to the specific problem. The refining pattern adds specific structure or behavior to the refined pattern. For example, the Factory Method pattern [2] refines the Template Method. The Factory Method specifies the concrete class that the superclass creates. On the Provides Context relationships, a pattern provides context to other patterns. The context of each patterns becomes more specific according to the granularity of the system s components. For example, the Component pattern [6] provides the context to the Configuration Parameters pattern [6]. The Configuration Parameters pattern provides a certain degree of variability to component s behavior. The Configuration Parameters can be used when the Component pattern is used. To measure the abstraction level of patterns, the proposed metric has two principles below: Patterns that use, refine, or provides context to other patterns, patterns which are more generalized, and patterns that are applied before other patterns have higher abstraction level. Patterns used, refined, or provided context by other patterns, patterns that are more specific, and patterns that are applied after other patterns have lower abstraction level.

The proposed metric counts the quantity of substructure or sub-behavior of each pattern. We assume the above-mentioned relationships mean the existence of substructure of sub-behavior. We will present an intuitive explanation and a formal definition. reference: 6 backward reference: 0 Observer reference: 0 backward reference: 6 MVC Composite Prototype Singleton Strategy Flyweight reference: 1 backward reference: 2 Fig. 1. Inter-pattern relationships 2.1 Intuitive explanation of the proposed metric The reference count of a pattern is the total number of patterns that the pattern refers transitively. The backward reference count of a pattern is the total number of patterns that refers the pattern transitively. In Figure 1, ellipses indicate patterns, arrows indicate asymmetric inter-pattern relationships. For example, the MVC pattern transitively refers six patterns, so the reference count of the MVC patterns is six, and the backward reference count of the MVC pattern is zero because no pattern refers the MVC pattern. In the same way, the reference count of Composite pattern is two, and backward reference count is one. Patterns often delegate details into other patterns. Conversely, a pattern used by other patterns is delegated details from other patterns. The metric score of a pattern is a difference between the reference count and the backward reference count of the pattern. In the example shown in Figure 1, the metric score of MVC pattern is six, and of the Composite pattern is one. Therefore, developers can see that the MVC pattern is more suitable for architectural design.

2.2 Formal definition of the proposed metric The reference count of a pattern is the total number of patterns that the pattern can reference transitively on the graph. The graph is composed of patterns (vertices) and inter-pattern relationships (edges). The backward reference count of a pattern is the total number of patterns that references the pattern transitively on the graph. P is the set of N patterns for which we want to calculate the metric score. P = {p 1, p 2,... p n }, n N. The asymmetric relationship between a pattern p 1 and another pattern p 2, p 1, p 2 P, is represented as p 1, p 2. Therefore, the set of the relationships R is represented as R P P. (P, R) is a directed graph. R + is a transitive closure on R. R + is defined as below: R 1 R 2 = { p 1, p 3 p 2 P ( p 1, p 2 R 1 p 2, p 3 R 2 )}. R 1 = R. R n+1 = R n R. R + = R i. i=1 In addition, the set of patterns that can be retrieved transitively from a certain pattern p is a descendant of p, represented as D(p). The set of patterns that a certain pattern p can be retrieved transitively are ancesters of p, represented as A(p). D(p) = {p 0 p, p 0 P p, p 0 R + } P. A(p) = {p 0 p 0, p P p 0, p R + } P. A pattern with many ancestors tends to be a part of other patterns. A pattern that has many descendants tends to use other patterns. Where D(p) denotes the number of patterns included in D(p), and A(p) denotes same of A(p), the abstraction level of a certain pattern p is defined as: a(p) = D(p) A(p). Since the metric depends on the relationships between patterns, the user should recompute the metric when the set of patterns are changed. 2.3 Visualization Developers cannot understand intuitively abstraction levels only from numbers. In this section, we propose a visualization technique that uses the abstraction level.

In this technique, patterns with larger values for a(p) should be positioned above patterns with smaller values for a(p) should be positioned below. Only the vertical axis makes sense. In Figure 2, proposed visualization technique positions GoF s design patterns. Ellipses indicate patterns and arrows indicate asymmetric inter-pattern relationships. The abstraction level a(p) is used to position each pattern. 8 5 Interpreter Abstract Factory 3 Chain of Responsibility Builder Strategy 2 Mediator Decorator Visitor State Proxy 1 Iterator 0 Observer Facade Template Method Command Adapter -1 Bridge -2 Composite -3 Flyweight -4 Memento -5 Factory Method -6 Prototype -12 Singleton Fig. 2. GoF design patterns where vertical position depends on the score a(p), the abstraction level 3 Visual Demo of the Metric To experiment the metric and visualization techniques, we built a tool that calculates and displays the abstraction level of each pattern. The results are shown in Figure 2 and 3. In Figure 2, we used Uses, Refines, and Provides context relationships. The Interpreter and the Abstract Factory have high abstraction levels. The Interpreter references many other patterns, such as Visitor, Iterator, and Composite, directly or indirectly. In the opposite side of that, the figure also shows that Prototype pattern and Singleton pattern have lower abstraction level. Actually, the Prototype and Singleton patterns are referred directly or indirectly by many other patterns. Using this proposed visualization technique, shown in Figure 2, developers can easier understand that some patterns are close to architectural patterns, and other some patterns are close to idioms. In Figure 3, we performed a similar analysis on GoF s design patterns and PoSA s patterns. Some architectural patterns, such as Layers and Pipes and

Abstract Factory Strategy State Template Method Bridge Flyweight Factory Method Pipes and Filters Microkernel Reflection Layers Interpreter Composite Message Broker Whole-Part Builder Chain of Responsibility Visitor Command Processor Iterator Proxy Facade Composite Mediator MVC PAC Decorator Forwarder-Receiver Client-Dispatcher-Server Observer Command Connector Mini-Broker Acceptor View-Handler Memento Prototype Singleton 17 13 8 6 5 4 3 2 1 0-1 -3-4 -5-6 -10-13 -19 Fig. 3. GoF s design patterns and PoSA patterns. vertical position depends on the score a(p)

Filters, are at the top of the figure. This means they have highest abstraction level in shown patterns. Interestingly, Interpreter pattern (a kind of design pattern) is positioned above Broker pattern (a kind of architectural pattern). In the middle of Figure 3, patterns belonging to each pattern catalog are mixed. Patterns can be connected if there are relationships of at least two patterns from each pattern catalog. The abstraction level and its visualization cannot be obtained without the proposed metric. Moreover, the developer can apply the proposed metric to a set of patterns, possibly from different catalogs, as we have illustrated. 4 Related work Buschmann et al. proposed a classification of patterns: architectural patterns, design patterns, idioms [1]. This classification is based on abstraction level. Our metric can classify patterns into levels more than three. Cutumisu et al. have proposed four metrics for pattern catalogs: usage, coverage, utility and precision [7]. Those metrics use the number of patterns in a pattern catalog and the number of adapted/unadapted instances of patterns. In contrast, our metric uses asymmetric inter-pattern relationships. Porter et al. have discussed about pattern language composition [8]. In the paper, Porter et al. have build the pattern map of the merged pattern collection. Our metric can be applied to the pattern even if the pattern collection is obtained by merging because our metric is only based on the asymmetric inter-pattern relationships. The proposed metric can add the positional information to the merged pattern map. There are researches about inter-pattern relationships [1, 4 6]. Noble has surveyed inter-pattern relationships and has roughly classified into three categories, such as Use, Refine, and Conflict. The Use and Refine relationships are asymmetric, but the Conflict relationship is unordered. Since our metric is based on asymmetric relationships, the metric works on Use and Refine relationships. Martin proposed two metrics on packages [9], such as Afferent Couplings (Ca) and Efferent Couplings (Ce). Our metric and Martin s OO-metrics is similar in the abstract structure of patterns/packages, however, our metric is for software patterns. Though our metric is defined as a simple subtraction, Martin s metrics use a more complex calculation. 5 Conclusion In this paper, we proposed a metric to measure the abstraction level of a pattern, based on asymmetric inter-pattern relationships. The proposed metric can add the positional information to the existing pattern map. Using pattern maps with the positional information obtained from the proposed metric, developers can understand the abstraction levels of patterns easily. The proposed metric has the following advantages:

The metric can be applied across pattern catalogs because the method only uses inter-pattern relationships. The metric scores can be used as a hint to position patterns in a pattern map. And it has following disadvantages: The metric score is a relative value, so it is not possible to compare scores from different sets of patterns. Before applying the metric, the user has to obtain inter-pattern relationships on the targeted set of patterns. We plan to perform experiments to validate that our metric makes the experience of developers involved. References 1. Frank Buschmann, Regine Meunier, Hans Rohnert, Peter Sommerlad, and Michael Stal. Pattern Oriented Software Architecture: A System of Patterns. Wiley, New York, 1996. 2. Eric Gamma, Richard Helm, Ralph Johnson, and John Vlissides. Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley, 1994. 3. E. Krasner and Stephen T. Pop. A cookbook for using the model-view-controller user interface paradigm in smalltalk-80. Journal of Object-Oriented Programming, Vol. 1, No. 3, pp. 26 49, 1988. 4. Walter Zimmer. Relationships between design patterns. In Pattern Languages of Program Design Vol.1, pp. 345 364. Addison-Wesley, 1995. 5. James Noble. Classifying relationships between object-oriented design patterns. In Proceedings of 1998 Australian Software Engineering Conference (ASWEC 98). IEEE CS Press, 1998. 6. Markus Volter. Server-side components - a pattern language. In proceedings of EuroPLoP 2000, 2000. 7. M. Cutumisu, C. Onuczko, D. Szafron, J. Schaeffer, M. McNaughton, T. Roy, J. Siegel, and M. Carbonaro. Evaluating pattern catalogs: the computer games experience. In Proceeding of the 28th international conference on Software engineering (ICSE2006), pp. 132 141, 2006. 8. Ronald Porter, James O. Coplien, and Tiffany Winn. Sequences as a basis for pattern language composition. Science of Computer Programming, Special issue on new software composition concepts, Vol. 56, pp. 231 249, 2005. 9. Robert Martin. OO design quality metrics, 1994. http://www.objectmentor.com/ resources/articles/oodmetrc.pdf. Appendix means the direct product of two sets. means and. means inclusion of the left-side argument by the right-side argument. i=1 means the union of the following sets. S means the number of elements included in set S.