Csci 490 / Engr 596 Special Topics / Special Projects Software Design and Scala Programming Spring Semester 2010 Lecture Notes Introduction to Patterns Created: 19 August 2004. Revised: 13 April 2010 Concept of Design Pattern Arose originally in the field of (building) architecture in 1970’s – Christopher Alexander Imported into software architecture and design in late 1980s and 1990s 1 Pattern Describes a particular recurring design problem that arises in specific design contexts Presents a well-proven generic scheme for its solution The solution scheme is specified by describing its constituent components, their responsibilities and relationships, and the ways in which they collaborate 1 Characteristics of Patterns Describe solutions to recurring problems that arise in specific design situations. Distilled from practical experience Describe a group of components (e.g., classes or objects), how the components interact, and the responsibilities of each component. Higher level abstractions than classes or objects. Provide vocabulary for communication among designers Choice of name for pattern is very important. 2 Characteristics of Patterns (cont.) Help document architectural vision of a design If vision clearly understood, then less likely violated when system modified Provide conceptual skeleton for solution, encourage the construction of software with welldefined properties Are building blocks for construction of complex designs Help designers manage complexity of software 3 Descriptions of Patterns Context Problem Solution 4 Descriptions of Patterns Context Describes situation in which design problem arises 5 Descriptions of Patterns Problem Describes problem that arises repeatedly in the context set of forces -- aspects that must be considered when attempting a solution requirements the solution must satisfy e.g., efficiency constraints that must be considered e.g., use of a certain algorithm or protocol desirable properties of a solution e.g., easy to modify 6 Descriptions of Patterns Solution Describes a proven solution to the problem Specifies a configuration of elements to balance the forces associated with the problem Describes static structure of the configuration, identifying components and connectors relationships among the components Describes dynamic runtime behavior of the configuration, identifying control structure of components and connectors 7 Categories of Patterns Architectural patterns Design patterns Idioms 8 Categories of Patterns Architectural patterns “An architectural pattern expresses a fundamental structural organization schema for software systems. It provides a set of predefined subsystems, specifies their responsibilities, and includes rules and guidelines for organizing the relationships between them” High-level abstraction Fundamental design decision in development of a software system Independent of the implementation language Example: Pipes and Filters pattern 9 Categories of Patterns Design patterns “A design pattern provides a scheme for refining the subsystems or components of a software system, or the relationships between them. It describes a commonlyrecurring structure of communicating components that solves a general design problem within a particular context.” Mid-level abstraction Affects the structure of a subsystem Independent of the implementation language Examples: Adapter (or Wrapper) pattern Iterator pattern Strategy (or Policy) pattern 10 Categories of Patterns Idioms “An idiom is a low-level pattern specific to a programming language. An idiom describes how to implement particular aspects of components or the relationships between them using the features of the given language” Low-level abstraction Language-specific Examples: Language-specific iterator defined to implement interface Iterator in Java Counted Pointer for storage management of shared objects in C++ 11 References Frank Buschmann, Regine Meunier, Hans Rohnert, Peter Sommerlad, and Michael Stal. Pattern-Oriented Software Architecture: A System of Patterns, Wiley, 1996. Mary Shaw and David Garlan. Software Architecture: Perspectives on an Emerging Discipline, Prentice-Hall, 1996. 12 Acknowledgement This work was supported by a grant from Acxiom Corporation titled “The Acxiom Laboratory for Software Architecture and Component Engineering (ALSACE).” 13