Observations
Engineering=Problem Solving Introduction to Patterns and Many problems recur. Many problems have the same (or at least similar) Design Patterns solution structure.
Exact solution is dependent on the context Eunjee Song A more experienced person can solve new problems faster and better. Dept. of Computer Science Fundamental to any engineering discipline (even Baylor University any science): a common vocabulary for expressing its concepts, and a language for relating them together. Some slides adapted from slides by R. France and B. Tekinerdogan
Eunjee Song Deign Patterns Intro-1 Eunjee Song Deign Patterns Intro-2
Electrical Engineering Patterns Mechanical Engineering Patterns
Eunjee Song Deign Patterns Intro-3 Eunjee Song Deign Patterns Intro-4
Chemical Engineering Patterns Software Engineering Patterns
Eunjee Song Deign Patterns Intro-5 Eunjee Song Deign Patterns Intro-6
1 Origin of the term "pattern” Pattern: Problem-Solution-Context
Timeless Way of Building (Oxford University Press, 1970)
Work on software development patterns stemmed from work on patterns from building architecture carried out by Christopher Alexander.
Eunjee Song Deign Patterns Intro-7 Eunjee Song Deign Patterns Intro-8
What are software patterns? Patterns Solve Software Structural Problems like...
Patterns are intended to capture the best Abstraction, available software development experiences in Encapsulation the form of problem-solution pairs. Information hiding A pattern outlines solutions to a family of software development problems in a particular Separation of concerns context. Coupling and cohesion A pattern outlines a process for transforming problems targeted by the problem to solutions Separation of interface and characterized by the pattern. implementation Single point of reference Divide and conquer
Eunjee Song Deign Patterns Intro-9 Eunjee Song Deign Patterns Intro-10
Patterns Solve Pattern Types
Requirements Patterns: Characterize families of Non-functional Problems like... requirements for a family of applications e.g., checkin-checkout pattern: can be used to obtain requirements for library systems, car rental systems, video Changeability systems, etc. Architectural Patterns: Characterize families of Interoperability architectures e.g., Broker pattern: can be used to create distributed Efficiency systems in which location of resources and services is transparent (e.g., the WWW) Reliability Other examples: MVC, Pipe-and-Filter, Multi-Tiered Testability Design Patterns: Characterize families of low-level design solutions Reusability Examples: Gang of Four (GoF) patterns Programming idioms: Characterize programming language specific solutions
Eunjee Song Deign Patterns Intro-11 Eunjee Song Deign Patterns Intro-12
2 Example of an Architectural Pattern - MVC Solution Outline: Split Application Model-View-Controller (MVC) Pattern into 3 Areas:
Context: Developing user-interfaces (UIs ) The Model component: encapsulates core
Problem: How to create a UI that’s resilient to functionality; independent of input/output changes such as changes in look-and-feel representations and behavior. windowing system, changes in functionality. The View components: displays data from the Factors: changes to UI should be easy and possible modldel componen ttht; there can be mu ltilltiple v iews at run-time; adapting or porting the UI should not for a single model component. impact the implementation of the core functionality. The Controller components: each view is associated with a controller that handles inputs; the user interacts with the system via the controller components.
Eunjee Song Deign Patterns Intro-13 Eunjee Song Deign Patterns Intro-14
Patterns Summary Patterns, Architectures & Frameworks
A pattern addresses a recurring software development problem that arises in a particular There can be confusion between patterns, context, and outlines a solution for it. architectures and frameworks. A pattern captures ‘best practices’ in software development (the intention! ). Architectures model software structure at A pattern should be based on actual experiences in the highest possible level, and give the industry overall system view. An architecture can use Patterns provide a common vocabulary for, and many different patterns in different understanding of ‘best practices’. components Developers can refer to a pattern by name (e.g., the Adapter pattern) and others familiar with the pattern will not need further description
Eunjee Song Deign Patterns Intro-15 Eunjee Song Deign Patterns Intro-16
Patterns, Architectures & Frameworks Summary of Differences (cont...) Patterns are more general and abstract than frameworks. A pattern is a description of a Patterns are more like small-scale or local problem-solution pair, not a solution (or problem) architectures for architectural components itself. or sub-components A pattern cannot be directly implemented. An Frameworks are partially completed implementation is an example of a pattern. software systems that may be targeted at Patterns are more primitive than frameworks. A a particular type of application. These are framework can employ several patterns. tailored by completing the unfinished components.
Eunjee Song Deign Patterns Intro-17 Eunjee Song Deign Patterns Intro-18
3 Gang of 4 (GoF) Design Pattern Scope Criterion Classification Purpose categories described in “Design Patterns:…” by Scope determines whether a pattern applies to Gamma, Helm, Johnson and Vlissides; Addison-Wesley classes or objects Creational Classes Patterns that can be used to make object creation more flexible class relations (e.g., Abstract Factory) or restrict creation activities (e.g., inheritance structures (static-fixed at compile-time) Singleton). examples: Factory Method (creation); Adapter HlHelp mak e a syst em i idndepen den t o fhf how o bjtbjects are crea tdted, (t(struct ural) l)It; Interpret er, T empl ltMthd(bhate Method (behavi oral) composed, and represented (i.e., allows one to vary how Objects objects are created, composed, and represented) object relations. Structural dynamic (can be changed at run-time) Concerned with creating flexible mechanisms for composing examples: Abstract Factory, Builder, Singleton objects to form larger of structures (creation); Adaptor, Bridge, Facade (structural); Iterator, Behavioral Observer, Visitor (behavioral) Concerned with creating flexible algorithms and with assigning responsibilities to classes
Eunjee Song Deign Patterns Intro-19 Eunjee Song Deign Patterns Intro-20
Catalog of 23 Design Patterns by GoF Facade Pattern: Interfacing to subsystems Purpose Observer Pattern: Maintain consistency across Creational Structural Behavioral redundant state, also called Publisher-Subscriber Class Factory Method Adapter (class) Interpreter Template Method Composite Pattern: Modeling of dynamic aggregates Abstract Factory* Adapter (object)* Chain of Responsibility Strategy Pattern: Interface to a task implemented by Prototype Bridge* Command* Sc different algorithms * * o Builder Composite Iterator Object pe Singleton Decorator* Mediator Adapt er P att ern: I nt erf ace t o old syst ems (l egacy Facade Observer* systems) Flyweight State Proxy Strategy * Bridge Pattern: Interfacing to existing and future Visitor* systems Scope: domain over which a pattern applies, Purpose: reflects what a pattern does Proxy Pattern: Reduces the cost of accessing * : patterns to be covered with a Document Editor (Lexi) Example and/or an Asteroids game example objects
Eunjee Song Deign Patterns Intro-21 Eunjee Song Deign Patterns Intro-22
Why Study Design Patterns? Why Study Design Patterns? (cont…)
Reuse existing, high-quality solutions to commonly recurring problems Improve individual learning and team learning Establish common terminology to improve Improve the modification of model/code communications within teams Facilitate adoption of improved design Shift th e l evel of thi nki ng t o a hi gh er alternatives, even when patterns are not used perspective (i.e., help us see the forest AND explicitly the trees) Decide whether I have the right design, not just one that works.
Eunjee Song Deign Patterns Intro-23 Eunjee Song Deign Patterns Intro-24
4