Abstract Factory Pattern
Source:: Software Design Patterns - Best Practices for Software Developers
Definition
Defining an interface to create families of related or dependent objects without specifying their concrete classes.
An abstract factory can be thought of as a super factor or a factory of factories. The pattern achieves the creation of a family of products without revealing concrete classes to the client.
An Abstract Factory should be used where a system must be independent of the way the objects it creates are generated or it needs to work with multiple types of objects.
# Example
An example that is both simple and easier to understand is a vehicle factory, which defines ways to get or register vehicles types. The abstract factory can be named AbstractVehicleFactory. The Abstract factory will allow the definition of types of vehicle like “car” or “truck” and concrete factories will implement only classes that fulfill the vehicle contract (e.g. Vehicle.prototype.drive and Vehicle.prototype.breakDown).
| |
# Resources
- [Learning JavaScript Design Patterns]( https://www.patterns.dev/posts/classic-design-patterns
- Abstract Factory Design Pattern in Java | DigitalOcean