19

I'm learning about Design Patterns and found the Builder design pattern. What are the benefits of this design pattern and when should I use it? I surf www.dofactory.com and www.blackwasp.com but still don't understand the benefits. By the by, I'm new to design patterns so please explain me with simple ones.

CuriousSuperhero
  • 6,531
  • 4
  • 27
  • 50
kevin
  • 13,559
  • 30
  • 79
  • 104

4 Answers4

26

The Builder Design Pattern helps us to slice the operations of building an object. It focuses on constructing a complex object step by step. It also enforces a process to create an object as a finished product. That means an object has to be massaged by some instructed steps before it is ready and can be used by others.

Generally, It allows you to encapsulate the complex create logic.

Builder pattern is very much like factory pattern. The key difference between a builder and factory is that a builder is useful when you need to do lots of things to build an object.

For more information:
http://en.wikipedia.org/wiki/Builder_pattern
http://www.codeproject.com/KB/architecture/Builder_Design_Pattern.aspx

Kamyar
  • 18,639
  • 9
  • 97
  • 171
5

Builder design pattern helps to hide the complex logic in the builder class. Suppose we are developing a solution which constructs a large football field in different season as chosen by application users. We will create a builder class and pass the season info object in the builder class. Then the builder class is responsible construct the field according to seasons.

Naseef Chowdhury
  • 2,357
  • 3
  • 28
  • 52
2

Builder Design Pattern is USED when we wants instance to perform specific tasks in specific order see wiki Builder pattern for details.

Hopes that helps

Imran
  • 2,906
  • 1
  • 19
  • 20
2

Have you checked Wikipedia Builder page?

The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects.

Wikipedia example in Java. That should help.

MarcoS
  • 13,386
  • 7
  • 42
  • 63