Java Design Pattern Tutorial

Java Design Pattern Tutorial
Why it's important to learn and use design patterns:

Design Patterns provide easy to recognize and use OOP solutions to common problems. Design Patterns also solve specific programming challenges regarding usability and maintainability.
Design Patterms are broadly classified into 3 types

Creational patterns: Creational design patterns are design patterns that deal with object creation mechanisms, trying to create objects in a manner suitable to the situation.

Structural patterns: Structural design patterns are design patterns that ease the design by identifying a simple way to realize relationships between entities.

Behavioral patterns: Behavioral design patterns are design patterns that identify common communication patterns between objects and realize these patterns. By doing so, these patterns increase flexibility in carrying out this communication.


    Design Patterns and Definitions

Strategy Pattern
Strategy Pattern a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.

Observer Pattern
Observer Pattern defines a one-to-many dependency between objects so that when on object changes state, all its dependents are notified and updated accordingly.

Decorator Pattern
Decorator Pattern attaches additional responsibilities to an object dynamically. Decorators provide flexible alternative to sub classing for extending functionality.

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

Singleton Pattern
Singleton Pattern a class only has one instance and provide a global point of access to it.

Command Pattern
Command Pattern encapsulates a request as an object, there by letting you parameterize clients with different requests, queue or log requests, and support undoable operations.

Adapter Pattern
Adapter Pattern converts the interface of a class into another interface the client expect. Adapter lets classes work together that couldn’t otherwise because of incompatible interfaces.

Template Method
Template Method defines the skeleton of an algorithm in an operation deferring some steps to subclasses. Template method lets subclasses refine certain steps of an algorithm without changing the algorithm’s structure.

Iterator Pattern
Iterator Pattern provides a way to access the elements of an aggregate object sequentially without exposing its underlying representation.

Composite Pattern
Composite Pattern objects into tree structure to represent part whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.

State Pattern
State Pattern object to alter its behavior when it’s internal state changes. The object will appear to change its class.

Proxy Pattern
Proxy Pattern surrogate or placeholder for another object to control access to it.

Compound Pattern
Compound Pattern two or more patterns into a solution that solves a recurring or general problem.

Facade Pattern
Facade Pattern defines a unified interface to a set of interfaces in a subsystem. Façade defines a higher level interface that makes the subsystem easier to use.

Abstract Factory Pattern
Abstract Factory Pattern provides an interface for creating families of related or dependent objects without specifying concrete classes.

Builder Pattern
Builder Pattern is to find a solution to the telescoping constructor. The telescoping constructor anti-pattern occurs when the increase of object constructor parameter combination leads to an exponential list of constructors. Instead of using numerous constructors, the builder pattern uses another object, a builder that receives each initialization parameter step by step and then returns the resulting constructed object at once.

Reference:Head first Design Patterns