0% found this document useful (0 votes)
32 views

Design Patterns: The Power of Reusable Solutions

The document discusses design patterns, which are reusable solutions to common problems in object-oriented software design. It describes the basics of design patterns, including that they are language-independent and based on object-oriented principles. The broad categories of design patterns are creational for object creation, structural for object organization, and behavioral for object behavior and interactions. It provides details on some of the most commonly used GoF (Gang of Four) patterns, including Factory Method, Abstract Factory, Singleton, Adapter, Composite, Decorator, Facade, Proxy, Template Method, Command, Observer, State, and Strategy.

Uploaded by

saravananvam
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

Design Patterns: The Power of Reusable Solutions

The document discusses design patterns, which are reusable solutions to common problems in object-oriented software design. It describes the basics of design patterns, including that they are language-independent and based on object-oriented principles. The broad categories of design patterns are creational for object creation, structural for object organization, and behavioral for object behavior and interactions. It provides details on some of the most commonly used GoF (Gang of Four) patterns, including Factory Method, Abstract Factory, Singleton, Adapter, Composite, Decorator, Facade, Proxy, Template Method, Command, Observer, State, and Strategy.

Uploaded by

saravananvam
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 30

Design Patterns

The Power of Reusable Solutions


Click to edit Master subtitle style

7/28/12

The Basics of Design Patterns


Language independent Based on Object Oriented Design principles Tested and Proven GoF (Gang of Four) patterns standard Named after four pioneer guys who authored "Design Patterns"- Elements of Reusable ObjectOriented Software Using/developing the right pattern requires identification of a pattern of problems encountered in a system.

7/28/12

Design solutions to common problems encountered in designing an object oriented system.

The Broad Categories

Based on purpose:
Creational For scenarios related to creation of an object. Structural For scenarios related to organization of objects. Behavioral For scenarios related to an object behavior.
7/28/12

Based on scope:
Object based

GoF Patterns
7/28/12

Factory Method
7/28/12

But Isnt this just overriding?


Object Oriented Principles SOLID - Guidelines. Design Patterns Reusable designs based on principles, built using OO concepts. Proven solutions to commonly faced problems. Not spending time identifying solutions to recurring problems = Increased Productivity.

7/28/12

Object Oriented Concepts (Building blocks) Encapsulation, Abstraction, Inheritance and Polymorphism.

Abstract Factory
7/28/12

Singleton
7/28/12

Singleton - Thread safety


7/28/12

Singleton - Thread safety


7/28/12

Singleton - Eager Initialization


7/28/12

Singleton DoubleChecked Locking


7/28/12

Singleton Optimal Solution


7/28/12

Adapter - Object
7/28/12

Adapter - Class
7/28/12

Composite
7/28/12

Decorator
7/28/12

Faade
7/28/12

Proxy
7/28/12

Template Method
7/28/12

Command
7/28/12

Observer
7/28/12

State
7/28/12

Strategy
7/28/12

Cheat Sheet
Pattern Factory method Abstract Factory Note Analogy 7/28/12 Object gets created Having a factory to in the factory manufacture goods. Category decides the Choosing between factory factories depending on needs. A single object for a Government (cannot type across the VM afford to have more than one) Making two Power adapter for incompatible but different pin types related objects work by introducing a mediating class. Organizing objects in Directory/Tree a tree and structure. transparently manipulating them.

Singleton

Adapter

Composite

Cheat Sheet
Pattern Decorator Faade Note Add value on top of an existing object. Analogy 7/28/12 Themes for Mobile/PCs Simplify solutions by Faade around a encapsulating construction site. discreet complex implementations. An object pretending A bank loan agent to be another to hide who simplifies the complexity. process. Implement behaviors A subcontract. Not that are standard every aspect of the and leave the others job needs to be to subclasses. subcontracted. Map invokers to workers at runtime. A programmable remote control.

Proxy

Template Method

Command

Cheat Sheet
Pattern Observer Note Analogy 7/28/12 Notify all interested Stock prices monitor objects about a state Different persons change. investing in the same stock would be interested to stay up to date. An object oriented state machine Convert behaviors to strategies and use them interchangeably. A vending machine. Transportation I can choose how I want to get to my destination just when I need to travel, depending on my needs.

State Strategy

What about the other patterns?

Most popular patterns have been covered. Understanding these patterns should be a good start for understanding the rest. It is possible to define our own design patterns (if necessary), depending on the patterns of problems encountered in our applications. J2EE design patterns are different from these (core Java) design patterns, though the driving principles are the same.
7/28/12

Questions?
7/28/12

References

http://sourcemaking.com/design_patterns

http://java.sun.com/blueprints/corej2eepatterns/Patterns / (for J2EE design patterns)

7/28/12

Head First Design Patterns, Kathy Sierra & Bert Bates

You might also like