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).
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).