I am learning factory method
design pattern now, before that I learned simple factory
pattern.
I thought simple factory
is useful because it transfer the if/else
control flow to factory so the purity of product can be reserved. And then I learned factory method
pattern, and I thought it is complex and beautiful.
However, it occurred to me that there are no if/else
control flow in factory method
pattern any more, client know which product it will use and client choose corresponding factory.
For example
Factory factory = new SpecificFactory;
Product product = new SpecificProduct;
well, since client know which product they want to use(no if/else
control), why just simple new SpecificProduct why need extra factory?
I searched for it but didn't find satisfying answer.
In fact, what I want to ask is like Why do we need Abstract factory design pattern? except for this one is factory method not abstract factory.