Single Responsibility Principle (SRP)

Single Responsibility Principle (SRP) image
Single Responsibility Principle (SRP) is a design principle stating that a class or function should have only one job or reason to change. When each unit of code does exactly one thing, it becomes much easier to understand, modify, and test in isolation. 

It has a direct connection to testability: clear, focused responsibilities make it straightforward to write and maintain tests because failures point to a single, well-defined concern rather than a tangle of mixed logic. 

SRP is one of the SOLID principles and closely related to DRY.

For example, a function that both fetches data and formats it for display violates SRP; splitting these into two functions makes each independently testable.
Explore MoT
QA Leadership Summit - The AI-Native Edge: Leading the Future of QA image
QALS Summer 2026: a leadership summit to move beyond AI testing pilots and build production-ready, AI-first QA organizations - powered by the BrowserStack AI Test Platform and 25+ connected AI agents
MoT Software Testing Essentials Certificate image
Boost your career in software testing with the MoT Software Testing Essentials Certificate. Learn essential skills, from basic testing techniques to advanced risk analysis, crafted by industry experts.
Into The Motaverse image
Into the MoTaverse is a podcast by Ministry of Testing, hosted by Rosie Sherry, exploring the people, insights, and systems shaping quality in modern software teams.
Subscribe to our newsletter