The differences between Abstract Factory and Builder Pattern
Abstract Factory: Focus a family of the product objects (wood factory, vinal factory, door, and window)
Builder Pattern: Focus on constructing a complex object.
Abstract Factory: In abstract factory, we focus on “what” is made. In the example, our question is what product will be?
Builder Pattern: In builder pattern, we focus on “how” it is made. In the example, the product will be fast & messy or slow & neat.
Abstract Factory: There are too many different types of factories (wood factory, vinal factory) and to build many products (door, window).
Builder Pattern: Focus on one product.
Abstract Factory: Abstract factory’s method call creates and return different objects. For example,
Public class B_ConcreteFactory extends AbstractFactory {
Public AbstractONE createONE() {return newB_ONE();}
Public AbstractTWO createTWO() {return newB_TWO();}
}
Builder Pattern: Builder Pattern’s method call partially build the object. For example,
Public class Builder_B extends AbstractBuilder {
Public Product build_ONE( Product p) {…)
Public Product build_TWO( Product p) {…)
}
Complement each other
*Both classes are type of abstract.
*Both patterns have defined two generic (Door & Window Factory) and (Builder).
*Both seem to produce some kind of generic output.