Simple factory and Factory Method Design pattern difference
Take a look at this link. The poster really well explained his question. Is he really right? if you look at his example, he makes new factory classes and in each factory class's method, returns specific class. So creating a new class and adding just one method which returns specific product doesn't violate open/closed but is useless at all.
My questions are:
1) factory method must not violate open/closed principle at all. Am I right?
2) when would you use the factory method pattern that is really world-life example and not just boring example which doesn't prove anything at all. If in an example, the same thing is shown as in the link I posted, then I don't think it's a good example.
3) if factory method must not violate open/closed, https://www.coursera.org/lecture/design-patterns/2-1-4-factory-method-pattern-LIUcy why does it look like in this link that it violates?
Please do your best to make me realize the whole point. I've been struggling for a month for this psychopath pattern and still interested what I should do to understand it.
Aucun commentaire:
Enregistrer un commentaire