Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Oh, that'd just be a NewThing() constructor. The ThingFactory() can probably take an argument specifying which implementation you need. It's almost always just a small function holding a conditional chain that you don't want to copy/paste all over the place. As a bonus, it's a named design pattern that you can find in basically any book about design patterns.

Whether it's actually worth using is another question, but at least it's a point of reference.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: