Labels

algorithms (22) Design Patterns (20) java (19) linux (14) Snippet (13) service mix (6) soa (4)

Template Method


"Defines the skeleton of the algorithm , and defers some implementation to the sub classes."

the above example makeDrink() calls

  1. addWater
  2. addFruit
  3. addIce
the addFruit implementation is left to the sub classes orange and apple juice makers

the method makeDrink is made final so that the steps of making the juice is not changed

State Design Pattern


"It allows to change the behavior of the object when the state of an object changes"


Memento

Memento

Mediator

mediator

Iterator

  • single responsibility, 
  • simplifies aggregator
  • does not expose implementation of aggregator

Strategy Pattern





  1. Defines a set of algorithms
  2. Makes them interchangeable
  3. clients have the option to select 
in the example below the client can tell the type of indexer to use in the dictionary
the behavior of indexer which changes is moved to another class there by separating
the class which changes and the one which does not change 
the dictionary delegates calls to search and sort to the indexer 

Chain Of Responsibility

CHAIN OF RESPONSIBILITY

Proxy

proxy

Composite

Composite

This Pattern is useful

  1. when there is a need for hierarchical structure
  2. when the leaf and non leaf are to be treated alike 
Example GUI: a text field is the simplest component
a form can be a complex component which can have a field.

Facade

Facade

Adaptor

Adaptor

Builder Pattern


"To create a complex object 
controlled by another class director
Build an object step by step"

Abstract Factory


Provides an interface for creating family of objects
Without knowing concrete classes 

Search 24 Bytes

Loading...