2015-08-13 23:54:40 +02:00
---
layout: pattern
title: Builder
folder: builder
2015-08-15 18:03:05 +02:00
permalink: /patterns/builder/
2015-08-20 21:40:07 +02:00
categories: Creational
2015-09-22 18:25:56 +05:30
tags:
- Java
- Gang Of Four
2015-12-28 15:52:44 +02:00
- Difficulty-Intermediate
2015-08-13 23:54:40 +02:00
---
2016-01-03 21:14:30 +01:00
## Intent
Separate the construction of a complex object from its
2015-08-13 23:54:40 +02:00
representation so that the same construction process can create different
representations.

2016-01-03 21:14:30 +01:00
## Applicability
Use the Builder pattern when
2015-08-13 23:54:40 +02:00
* the algorithm for creating a complex object should be independent of the parts that make up the object and how they're assembled
* the construction process must allow different representations for the object that's constructed
2016-01-03 21:14:30 +01:00
## Real world examples
2015-08-13 23:54:40 +02:00
* [java.lang.StringBuilder ](http://docs.oracle.com/javase/8/docs/api/java/lang/StringBuilder.html )
2015-08-15 18:03:05 +02:00
* [Apache Camel builders ](https://github.com/apache/camel/tree/0e195428ee04531be27a0b659005e3aa8d159d23/camel-core/src/main/java/org/apache/camel/builder )
2015-09-22 18:25:56 +05:30
2016-01-03 21:14:30 +01:00
## Credits
2015-09-22 18:25:56 +05:30
* [Design Patterns: Elements of Reusable Object-Oriented Software ](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612 )
2016-01-27 12:55:59 +05:30
* [Effective Java (2nd Edition) ](http://www.amazon.com/Effective-Java-Edition-Joshua-Bloch/dp/0321356683 )