← Path
Object-Oriented Programming · SOLID Principles in Python: A Realistic Refactor, Step by Step
0 XP- 1 current stop: learning
- 2 upcoming
- 3 upcoming
- 4 upcoming
- 5 upcoming
Finish after stop 5
Stop 1 of 5 · Invoice office: one clerk, three jobs
Trick to keep in mind+3 XP
S: one class, one reason to change. If sales and finance both edit it, split it.
A method that works out prices, formats the document and sends the email changes for three unrelated reasons, since each belongs to a different group of stakeholders. Any of those edits risks breaking the others. The Single Responsibility Principle says to give each reason its own small collaborator, so a change in one place stays in that place.
Read it once, then a question tests whether the trick stuck.