Skip to content
Veltoryx Technologies
ProLesson 3.1Intermediate8 min readUpdated 31 October 2026

Single Responsibility Principle

Learn the first SOLID principle: a class should have only one reason to change, how to find the hidden reasons in a class, and how to split it without overdoing it.

Picture a small restaurant. The chef cooks, the waiter serves tables, and the cashier prepares the bill. Now imagine one person doing all three jobs at once. When the kitchen gets busy, the tables wait. When a customer argues about the bill, the food burns. A problem in one job blocks the other two. Splitting the jobs between three people means each can focus, each can be replaced and each can be improved without disturbing the others.

Classes in a program behave the same way. This lesson starts a series of five lessons about the SOLID principles, the best-known set of rules for designing classes. Each letter in the word stands for one principle:

LetterPrincipleThe idea in one line
SSingle ResponsibilityA class should have one reason to change
OOpen/ClosedAdd new behaviour by adding code, not by editing old code
LLiskov SubstitutionA child class must work wherever its parent is expected
IInterface SegregationDo not force a class to depend on methods it does not use
DDependency InversionDepend on abstractions, not on concrete details

You do not need to memorise them as slogans. Each lesson shows the problem first, so that every principle feels like a natural answer to something that really hurts. We begin with the first one.

01The principle

A class should have one, and only one, reason to change.

The important words are "reason to change". It does not say "a class should do one thing" or "a class should have one method". It says something about change. A reason to change is usually a person or a team who may ask you to change the code: the finance department, the design team, the database administrator, the security team.

If a single class can be forced to change by three different groups for three different reasons, it has three responsibilities, and it breaks this principle.

Loading the rest of the lesson…