Design patterns and anit-patterns Flashcards
Abtract factory pattern
A factory except the factory itself is abstract. Factories usually are “create pizza factory” and what goes on the pizza are hard dependencies of the factory. The abstract factory helps bc the factory dependencies itself are abstract or interfaces. A good example would be a pizza that has a constructor dependency of a toppingFactory, this factory itself has a list property. On creation of the factory, you would add toppings to the list. Now the pizza has a factory, but the factory could have any topping in it, it isn’t a fixed item.
https://springframework.guru/gang-of-four-design-patterns/abstract-factory-design-pattern/
Program to an interface, not an implementation
Your program should avoid using class specific methods and instead focus on using interface methods. This way you will not have to worry about which class is being called so you can call the right method, each class will inherit/use the same interface and you can use the interface methods.
https://stackoverflow.com/questions/2697783/what-does-program-to-interfaces-not-implementations-mean