Archive for the ‘Creational 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

1

participants

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

 

In this video I have made an attempt to explain various aspects of factory pattern.

  1. Open the Object Browser from the View menu of Microsoft Visual Studio.
  2. Select .Net Framework 4 in Browse Menu
  3. Type ‘factory’ in the search text box and press search/enter option

You will get to see how extensively MS.Net Framework is using Factory framework.

factory

The Factory Design Pattern is probably the most used design pattern in modern programming languages like Java and C#. It comes in different variants and implementations.

If you are trying to learn this pattern then you got to know about simple factory pattern, Factory Method and Abstract Factory.

Factory Design Pattern – Part 1

Factory Design Pattern – Part 2