On Sunday, 3 February 2019 at 14:42:13 UTC, Ron Tarrant wrote:
This morning I was Googling "singleton replacement" and someone on another forum said Factory would do the job. Anyone have thoughts on that?

It's usually replaced with inversion of control: the service instance is passed as an argument to object constructors, a related pattern is service provider when you need to access many services. Though it needs a more involved code organization compared to singleton. As for testing, singletons can be tested if you provide a setter method that allows to set a custom singleton instance.

Reply via email to