Factory Pattern
- •
What it is
- •
a creational pattern that separates the logic of creating an object from the client code that uses it, so the client never depends directly on a concrete class
- •
- •
- •
Benefits
- •
loose coupling (client doesn't depend on concrete implementations), open for extension (new types added without touching client code), testability (creation can be mocked), reusability
- •
- •
Structure
- •
an
AbstractFactorydefines the interface every concrete factory must implement, each producing a family of related products * related
- •
- •
Related