Added real world example of Builder.

This commit is contained in:
Ilkka Seppälä 2015-02-24 22:42:19 +02:00
parent d6e6c32980
commit f22d4a3610

View File

@ -61,6 +61,9 @@
* the algorithm for creating a complex object should be independent of the parts that make up the object and how they're assembled * 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 * the construction process must allow different representations for the object that's constructed
**Real world examples:**
* [java.lang.StringBuilder](http://docs.oracle.com/javase/6/docs/api/java/lang/StringBuilder.html)
## <a name="factory-method">Factory Method</a> [&#8593;](#list-of-design-patterns) ## <a name="factory-method">Factory Method</a> [&#8593;](#list-of-design-patterns)
**Intent:** Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses. **Intent:** Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.