Presentation is loading. Please wait.

Presentation is loading. Please wait.

7 April 2004CSci 210 Spring 20041 Design Patterns 2 CSci 210.

Similar presentations


Presentation on theme: "7 April 2004CSci 210 Spring 20041 Design Patterns 2 CSci 210."— Presentation transcript:

1 7 April 2004CSci 210 Spring 20041 Design Patterns 2 CSci 210

2 7 April 2004CSci 210 Spring 20042 Creational Patterns Abstract Factory Builder Factory Method Prototype Singleton – used when it is appropriate to have exactly one instance of a class

3 7 April 2004CSci 210 Spring 20043 Structural Patterns Adapter (Wrapper) Bridge Composite Decorator Façade Flyweight Proxy

4 7 April 2004CSci 210 Spring 20044 Behavioral Patterns Chain of Responsibility Command Interpreter Iterator Mediator Memento Observer State Template method Visitor

5 7 April 2004CSci 210 Spring 20045 Visitor Pattern The purpose of the Visitor Pattern is to encapsulate an operation that you want to perform on the elements of a data structure. –In this way, you can change the operation being performed on a structure without the need of changing the classes of the elements that you are operating on. –Using a Visitor pattern allows you to decouple the classes for the data structure and the algorithms used upon them.

6 7 April 2004CSci 210 Spring 20046 Abstract Factory Pattern With the help of the Abstract Factory Pattern, we can leave the details of specific types of things to other classes –Let's say that you are making various types of car, and each car has different types of components you need to worry about. For example, say that you have the ability to build a Cadillac Dreadnaught, a Citroën BX- TRD, and a Fiat Avanti. –Each type of vehicle has the same overall structure that all cars share in common: i.e. an engine, wheels, steering, brakes, etc. For the sake of simplicity, let's say that a car consists of three components: Engine, Chassis, and Steering. –Naturally, you can't have the same types of Engine, Chassis or Steering in each car, because then the cars would all be the same. It won't do to mix- and-match components, either.

7 7 April 2004CSci 210 Spring 20047 Abstract Factory Pattern (continued) –You need all Cadillac parts to go with the Cadillac, and all Citroën parts to go with the Citroën, etc. –The different parts of the cars don't need to do the same thing, either: they need merely conform to an interface. LinkLink


Download ppt "7 April 2004CSci 210 Spring 20041 Design Patterns 2 CSci 210."

Similar presentations


Ads by Google