Two MoTacon attendees are on the left. The MoTaacon logo is in the center, and to the right a prompt to Get Your Ticket.

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
Influence, from the other side of the table image
What I learned about influence by becoming a stakeholder
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.
This Week in Quality image
Debrief the week in Quality via a community radio show hosted by Simon Tomes and members of the community
Subscribe to our newsletter