TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Solid Is Not Solid – Examining the Single Responsibility Principle

3 pointsby reedlawabout 5 years ago

1 comment

reedlawabout 5 years ago
I like using the concept of Cohesion to answer questions about &quot;what belongs where&quot;. But I didn&#x27;t understand the conclusion. The author goes through two refactors of a Rails controller. After adding a call to a mailer he says:<p>&gt; 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.<p>Then after adding a database statistic recorder:<p>&gt; 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.<p>Finally the author concludes:<p>&gt; 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.<p>How is it absolutely wrong when using cohesion as the paradigm agrees with SRP half the time?