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

> a factory can vary the return type, unlike a plain constructor

That's a language limitation and has nothing to do with the design pattern. You can do this just fine e.g. in Python.



You could do that more or less in Javascript by creating and initializing different member variables in the constructor depending on a constructor argument but I would hate you for it.




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

Search: