Hacker News new | past | comments | ask | show | jobs | submit login

Spring does it right. This is a IoC container btw, and not unique to spring.

This isn't a singleton, but a single instance of a object.

You can change the lifetime of an object, by changing a setting in the IoC container. From ApplicationLifetime To SessionLifetime quite easily. That solves the biggest problem of the singleton, which if you ever DO need more than one, it requires a refactoring.

I hate singletons, and I'm a iOS developer. So i'm continually mad about misuse of singletons(Working on legacy code).




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: