Presentation is loading. Please wait.

Presentation is loading. Please wait.

January 12, 2009 1 Introduction to Design Patterns Tim Burke References: –Gamma, Erich, et. al. (AKA, The Gang of Four). Design Patterns: Elements of Reusable.

Similar presentations


Presentation on theme: "January 12, 2009 1 Introduction to Design Patterns Tim Burke References: –Gamma, Erich, et. al. (AKA, The Gang of Four). Design Patterns: Elements of Reusable."— Presentation transcript:

1 January 12, 2009 1 Introduction to Design Patterns Tim Burke References: –Gamma, Erich, et. al. (AKA, The Gang of Four). Design Patterns: Elements of Reusable Object – Oriented Software. Upper Saddle River, NJ: Addison-Wesley, 1994 –Grand, Mark. Patterns in Java, Vol. 1. Indianapolis: Wiley, 2002

2 January 12, 2009 2 Overview What’s a design pattern? Why design patterns? Brief History of design patterns What’s in a design pattern Grand’s general classifications of design patterns Synopsis of specific design patterns Summary Further Reading

3 January 12, 2009 3 What’s a Design Pattern? “[A] pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever using it the same way twice.” – ( Christopher Alexander quoted by Gamma, et. al. 2)‏ “Reusable solutions to recurring problems that we encounter during software development.” – (Grand 1)‏

4 January 12, 2009 4 Why Design Patterns? “Designing object-oriented code is hard, and designing reusable object-oriented software is even harder.” – (Gamma, et.al 1)‏ Patterns enable programmers to “…recognize a problem and immediately determine the solution without having to stop and analyze the problem first.” -- (Grand 1) Provides a framework for communicating complexities of OO design at a high level of abstraction Bottom line: productivity

5 January 12, 2009 5 A Brief History of Design Patterns 1979--Christopher Alexander pens The Timeless Way of Building –Building Towns for Dummies –Had nothing to do with software 1994--Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides (the Gang of Four, or GoF) publish Design patterns: Elements of Reusable Object-Oriented Software –Capitalized on the work of Alexander –The seminal publication on software design patterns

6 January 12, 2009 6 What’s In a Design Pattern--1994 The GoF book describes a pattern using the following four attributes: nameThe name to describes the pattern, its solutions and consequences in a word or two problemThe problem describes when to apply the pattern solutionThe solution describes the elements that make up the design, their relationships, responsibilities, and collaborations are the results and trade-offs in applying the patternThe consequences are the results and trade-offs in applying the pattern All examples in C++ and Smalltalk

7 January 12, 2009 7 What’s In a Design Pattern--2002 Grand’s book is the latest offering in the field and is very Java centric. He develops the GoF attributes to a greater granularity and adds the Java specifics Pattern name—same as GoF attribute Synopsis—conveys the essence of the solution Context—problem the pattern addresses Forces—reasons to, or not to use a solution Solution—general purpose solution to the problem Implementation—important considerations when using a solution Consequences—implications, good or bad, of using a solution Java API usage—examples from the core Java API Code example—self explanatory Related patterns—self explanatory

8 January 12, 2009 8 Grand’s Classifications of Design Pattern Fundamental patterns Creational patterns Partitioning patterns Structural patterns Behavioral patterns Concurrency patterns

9 January 12, 2009 9 Fundamental Design Patterns Delegation—when not to use Inheritance Interface Abstract superclass Interface and abstract class Immutable Marker interface Proxy

10 January 12, 2009 10 Fundamental Design Pattern Functions “The most fundamental and important design patterns to know”– (Grand 51)‏ –Most other patterns user at least one of these –So ubiquitous that they’re often not mentioned

11 January 12, 2009 11 Creational Patterns Factory method Abstract Factory Builder Prototype Singleton Object pool

12 January 12, 2009 12 Creational Pattern Functions Provides guidance on how to create objects when their creation requires making decisions –“Decisions typically involve dynamically deciding which class to instantiate or which objects an object will delegate responsibility to”— (Grand 101)‏ –Value is to tell us how to structure and encapsulate the decisions

13 January 12, 2009 13 Partitioning Patterns Filter Composite Read-only interface

14 January 12, 2009 14 Partitioning Pattern Functions Follows the divide and conquer paradigm –“Provide guidance on how to partition classes and interfaces in ways that make it easier to arrive at a good design”– (Grand 175)‏

15 January 12, 2009 15 Structural Patterns Adapter Iterator Bridge Façade Flyweight Dynamic linkage Virtual proxy Decorator Cache management

16 January 12, 2009 16 Structural Pattern Functions “Describe common ways that different types of objects can be organized to work with each other”– (Grand 207)‏

17 January 12, 2009 17 Behavioral Patterns Chain of responsibility Command Little language Mediator Snapshot Observer State Null object Strategy Template method Visitor

18 January 12, 2009 18 Behavioral Pattern Functions These “…patterns are used to organize, manage, and combine behavior” – (Grand 303)‏

19 January 12, 2009 19 Concurrency Patterns Single threaded execution Lock object Guarded suspension Balking Scheduler Read/Write lock Producer-consumer Two-phase termination Double buffering Asynchronous processing Future

20 January 12, 2009 20 Concurrency Pattern Functions These patterns involve coordinating concurrent operations and address two primary problems –Shared resources –Sequence of operations

21 January 12, 2009 21 Summary Patterns enable programmers to “…recognize a problem and immediately determine the solution without having to stop and analyze the problem first.” -- (Grand 1) Patterns provide a framework for communicating the complexities of OO design at a high level of abstraction

22 January 12, 2009 22 Further Reading http://www.mindspring.com/~mgrand/pattern_synop ses.htmhttp://www.mindspring.com/~mgrand/pattern_synop ses.htm http://hillside.net/patterns/ http://hem.passagen.se/gumby/cs/patterns.html http://www.swtech.com/dpattern/ http://www.enteract.com/~bradapp/links/sw- pats.htmlhttp://www.enteract.com/~bradapp/links/sw- pats.html


Download ppt "January 12, 2009 1 Introduction to Design Patterns Tim Burke References: –Gamma, Erich, et. al. (AKA, The Gang of Four). Design Patterns: Elements of Reusable."

Similar presentations


Ads by Google