Reading the factory design pattern in the "Gang of the Four" book pp 111, I found it use the parameterised factory method
if (id == MINE) return new MyProduct();
if (id == YOURS) return new YourProduct();
I read some articles which said those "if statement" are actually bad smell. We need to use reflection or non-reflection registration to avoid that.
Anyone can shed some light here? I don't find any statement in the book. If any new design pattern book said this is a bad smell, please also let me know.
Aucun commentaire:
Enregistrer un commentaire