A new security requirement arrives: passwords must be hashed with bcrypt instead of MD5. Simple enough. You open the User class to make the change and find yourself scrolling past email-sending logic, database queries, and input validation before you even get to the hashing method. You make the change, run the tests, and three unrelated things break.
This is what happens when a class has too many reasons to change. The Single Responsibility Principle exists to prevent exactly this: one class, one job, one reason to be touched.
Latest Posts
Design Patterns Series #3 – Creational Patterns The feature request seemed simple: “We’re adding drone delivery next quarter.” You opened the order processing class, found…
How many parameters is too many? Four? Six? There’s a constructor somewhere in every codebase that crossed the line, the one where you have to count commas to figure out which argument goes where, and where passing null for “optional” fields became completely normal.
It always starts the same way. A new feature request lands in your inbox: “We need to add Google Pay.” You open the payment processing class, scroll through the if-else chain that already handles Stripe, PayPal, and BLIK, and feel that familiar anxiety – because touching this method means you could break everything else that already works.