Traditionally, Singleton creates its own instance, and it creates it only once. In this case, it is not possible to create a second instance.
If you use Dependency Injection, you can let the framework create a singleton for you. Singleton does not protect against other instances (i.e., has an open constructor), but the dependency injection infrastructure only creates an instance of one instance. In this case, you can create more instances for testing, and your object will not be cluttered with a single code.
Sjoerd
source share