View RSS Feed

Design Patterns

Design patterns in Java.

  1. Builder Pattern - Applicability & Examples

    by , 03-09-2012 at 08:15 PM
    Builder pattern could be used when:
    • Creation algorithms of complexed objects are not dependent upon parts that compose the objects.
    • System allows the representation of many different objects.


    Vehicle Manufacturer

    Consider an example of vehicle manufacture that creates bicycle, a car, a scooter and a motorcycle. In such case, builder would be the Vehicle Builder. Interface is being specified to build any kind of vehicle in the above list by using similar ...
  2. Factory Pattern Applicability & Examples

    by , 03-09-2012 at 08:09 PM
    Factory pattern is most widely used pattern.

    E.g, graphical applications do their work along with shapes. In implementations, shapes are products and drawing frameworks are the clients. An abstract shape is responsible for the derivation of the shapes. Shape class defines the move operations and draw that shall be implemented by concrete shapes. Now let us assume that a particular command has been selected from menu so that to make a new circle. Shape type is being received by the ...
  3. Singleton Pattern Applicability & Examples

    by , 03-09-2012 at 07:43 PM
    Singleton Pattern according to its definition shall be only used if there is exact one instance of class and also when its accessibility is given from a global access point to the clients.Few real situations are given here where singleton is used:

    Logger Classes

    In design of the logger class the singleton pattern is used. Such classes are basically implemented as singletons so that to provide a global access point for all the components of application. For this purpose ...