Factory Design Pattern Advantages Factory pattern removes the instantiation of actual implementation classes from client code. Factory pattern makes our code more robust, less coupled and easy to extend. For example, we can easily change PC class implementation because client program is unaware of this.
- What is the advantage of factory design pattern in Java?
- What is the purpose of factory design pattern?
- What is the benefit of having a factory to make objects?
What is the advantage of factory design pattern in Java?
Advantage of Factory Design Pattern
Factory Method Pattern allows the sub-classes to choose the type of objects to create. It promotes the loose-coupling by eliminating the need to bind application-specific classes into the code.
What is the purpose of factory design pattern?
The Factory Method pattern is a design pattern used to define a runtime interface for creating an object. It's called a factory because it creates various types of objects without necessarily knowing what kind of object it creates or how to create it.
What is the benefit of having a factory to make objects?
You can avoid creating duplicate objects (if your objects are immutable). The factory can return the same object for same set of parameters. You can create and return any subtype of the type that factory is designed to create. Replacing implementations without changing client code (calling code).