Stage 2 · Lesson 1 of 7
Single responsibility
The says a class should have one reason to change. A reason to change is a group of people or a kind of decision: pricing rules come from the business, the invoice layout from designers, the database from engineers.
An Invoice class that calculates, prints and saves itself changes for all three, so a layout tweak can break tax calculation. Split it, and each class stays small, focused and easy to test. is the related idea: the parts of a class should belong together. A useful test is to describe the class in one sentence without using "and".
Common trapreading it as "one method per class" and scattering code that always changes together across a dozen tiny classes.
A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock
Resources for this stage
Start with· follow one of these
- CoursePaidGrokking SOLID Design Principles
Design Gurus · Beginner · $50 one-time
One chapter per principle, each with the violation and the refactoring that fixes it
- CourseFreeMIT 6.102: Software Construction
MIT · Intermediate
Free: the Specifications and Interfaces and Subtyping readings explain substitution as contracts