Solid Is Not Solid – Examining the Single Responsibility Principle
- I like using the concept of Cohesion to answer questions about "what belongs where". But I didn't understand the conclusion. The author goes through two refactors of a Rails controller. After adding a call to a mailer he says: - > Creating a widget and sending an email about it sound like they belong together, so I would argue this change doesn’t materially affect the cohesion of this class. - Then after adding a database statistic recorder: - > The controller has nothing to do with databases, so this change feels like it reduces the cohesion of the class enough for us to question this change. - Finally the author concludes: - > Yet in both cases, the Single Responsibility Principle has been violated. This tells me that framing the concept of cohesion as the Single Responsibility Principle is absolutely wrong. - How is it absolutely wrong when using cohesion as the paradigm agrees with SRP half the time?