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

Singletons are useful and wide spread concepts. What is an anti pattern is implementing them in a way that's not thread safe (which is made worse if your singleton is mutable).

Letting DI frameworks handle your singletons is the best way to get the best of both worlds.



No no, singletons are pathological liars http://misko.hevery.com/2008/08/17/singletons-are-pathologic...

Atomic mutable global state is still mutable global state. DI containers mean you don't need a singleton but can just create a single instance which lets you scope it and does not mix lifetime duration and object properties.




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

Search: