Wednesday, December 12, 2012

Design Patterns

Definition:
Design Patterns represent solutions to problems which arise when developing a software within a particular context.

Types of Design Patterns
There are three types of design patterns
1. Creational Patterns: Creational Patterns deals with initializing and configuring classes and objects
2. Structural Patterns: Structural Patterns deals with decoupling the interface and implementation of classes and objects
3. Behavioral Patterns: Behavioral Patterns deals with dynamic interactions among societies of classes and objects

These three design patters are divided in to 22 different kinds of patterns as shown below.
 

1 comment:


  1. 1:Factory Method: The Factory method takes care of one product whereas the abstract factory pattern provides a way to encapsulate a family of products. This pattern is used to create concrete class instances without specifying the exact class type. We can say it is an Object creation pattern also. Here objects are created without knowing the class of the object. So basically the factory pattern is used wherever the sub classes are given the previledge of instantiating a method that can create an object.

    2:ABSTRACT FACTORY: Provides an interface for creating families of relegated or dependent objects without specifying their concrete classes.

    There are two types of Abstract Factories:
    •The simple Abstract Factory is an abstract class defining Factory methods to answer instances of concrete subclasses
    •The second form of Abstract Factory is an abstract class defining a common protocol of Factory methods.

    3:BUILDER: The Builder pattern helps us to separate the construction of a complex object from its representation so that the same construction process can create different representations. The Builder pattern is useful when the construction of the object is very complex. The main objective is to separate the construction of objects and their representations.


    4:PROTOTYPE: The prototype design pattern is a design pattern that is used to instantiate a class by copying, or cloning, the properties of an existing object. The new object is an exact copy of the prototype but permits modification without altering the original. This is a creational pattern as it is used to control class instantiation and object generation. The pattern is used to instantiate a new object by copying all of the properties of an existing object, creating an independent clone. This practise is particularly useful when the construction of a brand new object, using the new operator, is inefficient.

    5:SINGLETON: The singleton pattern is useful when a single, global point of access to a limited resource is required. It is more appropriate than creating a global variable as this may be copied, leading to multiple access points and the risk that the duplicates become out of step with the original. It focuses on how the object is created and ensures that there exists only one instance of the object.

    ReplyDelete