24
Infosp a spectrum of possibilities ctrum This presentation is the intellectual property of Infospectrum India Private Limited. Any unauthorized use, dissemination of the information, or copying of this presentation, in whole or in part, without the express written permission of Infospectrum India Private Limited is prohibited. Please send an email to i[email protected] to obtain written authorization

Design Patterns Presentation - Chetan Gole

Embed Size (px)

DESCRIPTION

An Introductory session of Design Patterns.

Citation preview

Page 1: Design Patterns Presentation -  Chetan Gole

Infospa spectrum of possibilities

ctrumThis presentation is the intellectual property of Infospectrum India Private Limited. Any unauthorized use, dissemination ofthe information, or copying of this presentation, in whole or in part, without the express written permission of InfospectrumIndia Private Limited is prohibited. Please send an email to [email protected] to obtain written authorization

Page 2: Design Patterns Presentation -  Chetan Gole

What is Design Pattern

Design pattern is a general reusable solution to a commonly occurring problem in software design.

A design pattern is not a finished design that can be transformed directly into code. It is a description or template for how to solve a problem that can be used in many different situations.

Infospa spectrum of possibilities

ctrumchetangole.com

Page 3: Design Patterns Presentation -  Chetan Gole

Infospa spectrum of possibilities

ctrumchetangole.com

Page 4: Design Patterns Presentation -  Chetan Gole

History Civil Engineer

Christopher Alexander.

Gang of four : Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides

Infospa spectrum of possibilities

ctrumchetangole.com

Page 5: Design Patterns Presentation -  Chetan Gole

Why Design Patterns

• To design a new software system quickly and efficiently.

• To understand a existing software system.

Infospa spectrum of possibilities

ctrumchetangole.com

Page 6: Design Patterns Presentation -  Chetan Gole

Types of Design Pattern

• Creational Design pattern

– Object creation.

• Structural design patterns

– Relationship between entities.

• Behavioural design patterns

– Communication between objects.

Infospa spectrum of possibilities

ctrumchetangole.com

Page 7: Design Patterns Presentation -  Chetan Gole

Observer Design Pattern

• Observer Design Pattern is a software design pattern in which an object, called the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by calling one of their methods.

• Type : Behavioral pattern.

Infospa spectrum of possibilities

ctrumchetangole.com

Page 8: Design Patterns Presentation -  Chetan Gole

Factory Design Pattern

• Define an interface for creating an object, but let the subclasses decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.

• Type : Creational pattern.

Infospa spectrum of possibilities

ctrumchetangole.com

Page 9: Design Patterns Presentation -  Chetan Gole

Singleton Design Pattern

• Ensure a class has only one instance, and provide a global point of access to it.

• Encapsulated “just-in-time initialization” or “initialization on first use”.

• Type : Creational pattern.

Infospa spectrum of possibilities

ctrumchetangole.com

Page 10: Design Patterns Presentation -  Chetan Gole

UML Diagram for Singleton

Infospa spectrum of possibilities

ctrumchetangole.com

Page 11: Design Patterns Presentation -  Chetan Gole

Strategy Design pattern

The strategy pattern (also known as the policy pattern) is a particular software design pattern, whereby algorithms can be selected at runtime.

Type : Behavioral pattern.

Infospa spectrum of possibilities

ctrumchetangole.com

Page 12: Design Patterns Presentation -  Chetan Gole

Adaptor Design pattern

The adapter pattern (often referred to as the wrapper pattern or simply a wrapper) is a design pattern that translates one interface for a class into a compatible interface.

Infospa spectrum of possibilities

ctrumchetangole.com

Page 13: Design Patterns Presentation -  Chetan Gole

Proxy Design Pattern

A proxy, in its most general form, is a class functioning as an interface to something else. The proxy could interface to anything: a network connection, a large object in memory, a file, or some other resource that is expensive or impossible to duplicate.

Type : Structural pattern.

Infospa spectrum of possibilities

ctrum

Page 14: Design Patterns Presentation -  Chetan Gole

Chain of responsibilitiesThe chain-of-responsibility pattern is a design pattern consisting of a source of command objects and a series of processing objects. Each processing object contains a set of logic that describes the types of command objects that it can handle and how to pass off those that it cannot to the next processing object in the chain

Type : Behavioral pattern.

Infospa spectrum of possibilities

ctrumchetangole.com

Page 15: Design Patterns Presentation -  Chetan Gole

Decorator Design pattern

The decorator pattern is a design pattern that allows new/additional behaviour to be added to an existing object dynamically.

Type: Structural patterns

Infospa spectrum of possibilities

ctrumchetangole.com

Page 16: Design Patterns Presentation -  Chetan Gole

Template method pattern

A template method defines the program skeleton of an algorithm. One or more of the algorithm steps are able to be overridden by subclasses to provide their own concrete implementation.

Type : Behavioral Design Pattern.

Infospa spectrum of possibilities

ctrumchetangole.com

Page 17: Design Patterns Presentation -  Chetan Gole

Builder pattern

The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects.

Type : Creational Design Pattern.

Infospa spectrum of possibilities

ctrumchetangole.com

Page 18: Design Patterns Presentation -  Chetan Gole

Façade pattern

A facade is an object that provides a simplified interface to a larger body of code, such as a class library.

Type: Structural Design Pattern.

Infospa spectrum of possibilities

ctrumchetangole.com

Page 19: Design Patterns Presentation -  Chetan Gole

Iterator pattern

The Iterator pattern is a design pattern in which iterators are used to access the elements of an aggregate object sequentially without exposing its underlying representation.

An Iterator object encapsulates the internal structure of how the iteration occurs.

Type : Behavioral Design Pattern.

Infospa spectrum of possibilities

ctrumchetangole.com

Page 20: Design Patterns Presentation -  Chetan Gole

Mediator Pattern

• Behavioural pattern

• Definition

– With the mediator pattern communication between objects is encapsulated with a mediator object. Objects no longer communicate directly with each other , but instead communicate through the mediator . This results in a more cohesive implementation of the logic and decreased coupling between the other objects.

Infospa spectrum of possibilities

ctrumchetangole.com

Page 21: Design Patterns Presentation -  Chetan Gole

Flyweight Pattern

• Structural Pattern

• Definition

– The Flyweight pattern provides a mechanism by which you can avoid creating a large number of 'expensive' objects and instead reuse existing instances to represent new ones.

Infospa spectrum of possibilities

ctrumchetangole.com

Page 22: Design Patterns Presentation -  Chetan Gole

Prototype pattern

• Creational pattern.

• Definition

– The Prototype pattern is basically the creation of new instances through cloning existing instances. By creating a prototype, new objects are created by copying this prototype.

Infospa spectrum of possibilities

ctrumchetangole.com

Page 23: Design Patterns Presentation -  Chetan Gole

State Pattern

• Behavioral patterns

• Definition

– The State pattern allows an object to alter its behaviour when its internal state changes. By using inheritance and letting subclasses represent different states and functionality we can switch during runtime. This is a clean way for an object to partially change its type at runtime.

Infospa spectrum of possibilities

ctrumchetangole.com

Page 24: Design Patterns Presentation -  Chetan Gole

Thank you…..• Good read about Design Patterns

– http://en.wikipedia.org/wiki/Design_pattern_(computer_science)

– http://sourcemaking.com/design_patterns

– http://java.sun.com/blueprints/patterns/index.html

– http://www.codeproject.com/KB/architecture/#Design Patterns

– http://msdn.microsoft.com/en-us/magazine/cc301852.aspx

– http://www.javacamp.org/designPattern/

– http://www.javaworld.com/channel_content/jw-patterns-index.html

– http://www.ibm.com/developerworks/java/tutorials/j-patterns201/

• About me– Email: [email protected]

– Web : chetangole.com

Infospa spectrum of possibilities

ctrumThis presentation is the intellectual property of Infospectrum India Private Limited. Any unauthorized use, dissemination ofthe information, or copying of this presentation, in whole or in part, without the express written permission of InfospectrumIndia Private Limited is prohibited. Please send an email to [email protected] to obtain written authorization

If this presentation contains your copyrighted material please contact me at : [email protected]