Presentation is loading. Please wait.

Presentation is loading. Please wait.

Design Patterns Introduction

Similar presentations


Presentation on theme: "Design Patterns Introduction"— Presentation transcript:

1 Design Patterns Introduction
Emerson Murphy-Hill

2 Design Patterns Inspired by architect Christopher Alexander
“Each 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 doing it the same way twice.” Design patterns are descriptions of communicating objects and classes that are customized to solve a general design problem in a particular context. The design pattern identifies the participating classes and instances, their roles and collaborations, and the distribution of responsibilities Building architect Christopher Alexander says, “Each 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 doing it the same way twice.” Even though Alexander was talking about patterns in buildings and towns, what he says is true about object-oriented design patterns. Our solutions are expressed in terms of objects and interfaces instead of walls and doors, but at the core of both kinds of patterns is a solution to a problem in a specific context.

3 Why Design Patterns? Experienced designers
Rarely start from first principles Apply a working “handbook” of approaches Patterns capture and pass on the knowledge of these experienced designers Software patterns are a first step toward a design handbook for software engineering So, a pattern provides the core of a solution that must be customized by the pattern user. Where do these “cores of a solution” come from? They come from experienced experts who have solved many, many problems. Over time, experienced designers implicitly stopped starting from scratch, and they start from their own “handbook” of approaches that have worked for them in the past. Well, documented design patterns are a passing down of this expert experience to the rest of us – in a handbook of designs, of sorts. In addition to providing skeleton designs for us to use, Design Patterns also give us a language. Two developers brainstorming a design will often discuss the various patterns they could possibly use. For example, one developer might say, “I think our notification system should use the Observer pattern.” The other developer will understand the idea being proposed based on his or her general understanding of the Observer pattern.

4 Design Patterns “Gang of Four” book Written in a classic 23 design patterns There are hundreds of patterns in the literature This is a picture of the famous book -- often called the “Gang of Four” book that moved patterns into the mainstream. In 1995, Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides published Design Patterns: Elements of Reusable Object-Oriented Software . Despite the fact that the book was written more than a decade ago – an eternity in the computer science field, the book is on most every professional’s shelf. The book contains 23 design patterns, though there are hundreds of design patterns in the literature.

5 Pattern Families (GOF)
Creational: Concerned with the process of object creation Singleton Factory Method Structural: Deal with the composition of classes or objects Composite Adapter Behavioral: Characterize the ways in which classes or objects interact and distribute responsibility Observer Strategy State The 23 design patterns in the Gang of Four book are divided into three families, Creational Patterns, Structural Patterns, and Behavioral patterns. Creational patterns are concerned with the process of object creation Structural patterns deal with the composition of classes or objects Behavioral patterns characterize the ways in which classes or objects interact and distribute responsibility. Next we will talk about one particular pattern, the Strategy pattern. The strategy pattern is a behavior pattern [click].


Download ppt "Design Patterns Introduction"

Similar presentations


Ads by Google