I just started Reading design patterns, understood well about the Factory pattern. So i red the disadvantage of factory pattern is if We add any class to heirarchy then we should modify the factory class.
In the above code if add "CreditCardAccount" to Account heirarchy then i should modify the Account factory class.so it is violation of open closed principle.
so as per the abstract factory pattern defination it is factory for factories
In the above code i have two issues.
If add a new branch like "CreditCardAccount"(which is base for CreditCardClassic and CreditCardPremier) which extends Account then i have to modify the Factory Creator class,
If add a BusinessAccount as a child (CheckingBusinessAccount and SavingsBusinessAccount) then i have to modify the AccountFactory class to add a method getBusinssAccount() method.So it also a violation of open closed princlple.
So what is the Use of using AbstractFactory over Factory pattern?The only thing i observed is if the above AbstractFactory example changed to Factory Pattern then in side the Factory class i have to write so many if else conditions.
can anybody explain in simple terminology?(not expecting too much technical terminology)
Design pattern is basically deals with the intent/motivation and kind of issue your are tying to resolve.
Abstract factory provides the abstraction to get the factory of product and factory pattern provides the abstraction to get the concrete product.
hope this clarifies..