DSA Factory
Free SOLID and design smells lessonsSOLID and design smells · Stage 0 · Change without pain · Step 1

Single responsibility

Why a class should have one reason to change, and how to see the second reason hiding in a class. About 12 minutes.

Quick check

Which question best tests whether a class follows the single responsibility principle?

  1. AHow many different people or concerns could ask me to change this class?
  2. BIs it under 100 lines?
  3. CDoes it have only one method?
Show the answer

How many different people or concerns could ask me to change this class?. One source of change is the principle.

Lock it in

4 questions on this idea

Short questions that apply the idea to new cases: trace it, work out a number, put steps in order. A wrong answer explains itself.

Answer them in your browserFree account, no card. Your progress is saved, and the idea comes back in a quick review later.
Sign up free to solve