Skip to main content

How does Singleton violate the single responsibility principle (SRP)?

Singleton violates the single responsibility principle (SRP) because it combines two different roles that should be split between different classes:

The business-logic role

For example, the Logger class is responsible for writing logs, ConfigManager for storing settings, Cache for caching data. That is their core responsibility.

The lifecycle-management role

Singleton forces those same classes to control their own creation, hold a reference to the single instance, and provide global access to it.

This design makes the class too "smart": it does not just solve a task, it also manages itself. This violates the SRP, under which a class should have only one reason to change.

When one part of the system must change because of the logic, and another because of the initialization approach, a change in one aspect affects the other. As a result, the code becomes less flexible, harder to test, and more tightly coupled to global state, which contradicts the idea of a clean, modular architecture.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.