Creational Design Patterns
Design Patterns Series Part 1
Abstract Factory
Intent
- Create an interface to
- decouple creation of families of related or dependent objects
- without specifying the concrete classes
- clients should be decoupled with how its products are created
- class library author should have a means of hiding the actual implementations of the products in the class library from the client
- client should have the ability to switch between multiple families of products
- a need to enforce that a family of related products need to be used together
- Client
- Abstract factory
- Abstract product
- Concrete factory
- Concrete product
Advantages and Disadvantages
- Isolates concrete classes
- Makes exchanging product families easy
- Promotes consistency among products
- Supporting new kinds of product is difficult
Builder
Intent
- Decouple the creation process of a complex object from
- its internal representation
- algorithm of creating a complex object should be independent of the parts that make up the object and how they are constituted
- construction process must allow different representation of the object that is being constructed
- Client
- Director
- Builder
- Concrete builder
- Product
Advantages and Disadvantages
- Finer control over construction process where products are constructed in a step by step fashion