Re:Singleton Is a Bad Idea
by moron4hire on Sunday April 10, 2022 @02:49PM
(#30980383)
The Singleton of .NET IoC containers is not the same thing as the Singleton pattern. It's called a Singleton because the DI controller will make sure only one instance is available. But the Singleton pattern has the class itself making sure it can have only one instance. The mixing of concerns is the problem with the Singleton pattern. With a DI controller, you can change the lifetime of the instance without having to change the class definition itself. With the Singleton pattern, changing the instance lifetime requires changing every utilization site.
[ Parent
| on HN ]
There are no comments on this comment yet.