Chapter 3. Building Factories to Create Objects
In object-oriented development terminology, a factory is a class for creating other objects. Usually this class has methods that accept some parameters and returns some type of object depending on the parameters passed.
In this chapter we will cover:
- How to create a simple factory
- What the Factory Method is, when to use it, and how to implement it for building a tool that can be connected to a variety of web resources
- What the Abstract Factory is, when to use it, and how it is different from the Factory method pattern
So why should we bother ourselves with factories instead of using direct object instantiation?
- Factories provide loose coupling, separating object creation from using specific class implementation. ...