Archive for the ‘Design Patterns’ Category

Builder pattern is all about separating the object construction from its representation. Below is the definition given by GOF in their classic design patterns book,

“Separate the construction of a complex object from its representation so that the same construction process can create different representations”.

Parse a complex representation, create one of several targets.

UML Class Diagram



The classes and/or objects participating in this pattern are:

  • Builder  (IPhoneBuilder)
    • specifies an abstract interface for creating parts of a Product object
  • ConcreteBuilder  (AndroidPhoneBuilder, ApplePhoneBuilder, WindowsPhoneBuilder)
    • constructs and assembles parts of the product by implementing the Builder interface
    • defines and keeps track of the representation it creates
    • provides an interface for retrieving the product
  • Director  (Manufacturer)
    • constructs an object using the Builder interface
  • Product  (MobilePhone)
    • represents the complex object under construction. ConcreteBuilder builds the product’s internal representation and defines the process by which it’s assembled
    • includes classes that define the constituent parts, including interfaces for assembling the parts into the final result

In this video I have discussed about overview of Builder Pattern and need of going for Builder Patter with the help of code samples. Later explained Builder pattern with the help of Mobile Phone Manufacturing System example.

Sometimes creational patterns are complementary: Builder can use one of the other patterns to implement which components get built. Abstract Factory, Builder, and Prototype can use Singleton in their implementations.

Builder focuses on constructing a complex object step by step. Builder returns the product as a final step, but as far as the Abstract Factory is concerned, the product gets returned immediately



Observer pattern is widely used in software development. You might be already using this pattern extensively but you may not be aware of it. Some of the real world examples are GUI Controls, Data Binding, File Watcher, Network Events and Model View Controller.

In this video I will discuss about 3 variations of this pattern

  1.        Traditional Observer Pattern – documented by Gang of four in design patterns book
  2.        Events and Delegates – Out of box Observer pattern in MS.Net Framework
  3.        IObservable<T> – new implementation of this pattern is added in Framework 4.0 Task Parallel Library

The Observer Design Pattern can be used whenever a subject has to be observed by one or more observers.

  •        It is a behavioral pattern
  •        It is also known as Publisher – Subscriber Pattern
  •        The observer pattern is a software design pattern in which an object, called the subject, maintains a list of its dependents,        called observers, and notifies them automatically of any state changes, usually by calling one of their methods.
  • Observer pattern is a way of notifying change to a number of classes