I was deeply inspired by Kent Beck’s article on cohesion. A particular point resonated with me, specifically when he discussed the opposing forces of cohesion and coupling:
Wait!? Isn’t coupling bad? But cohesion is good? But cohesion is coupling of subelements? Isn’t that bad? And good?
This is where I got stuck for a long time (years). What I was missing was the “Compared To What?” perspective…
This “compared to what” perspective struck a chord. Lately, I’ve been increasingly thinking that many discussions about software design techniques fall short because they fail to provide real-world code examples, making meaningful comparison impossible. By real code, I mean code extracted directly from real, functioning applications.
In my Code I like series focusing on Rails design techniques, and in future articles, I aim to address this gap. It’s a conscious decision to share snippets of code from our products, which are actively used Rails applications with substantial user bases. No artificial or fabricated examples here—just the genuine article.
While I dislike the phrase “real world” in the context of software design approaches, I use it intentionally here. I firmly believe that actual code should be an indispensable component in these conversations. A layer of reality exists between abstract conceptual descriptions and the code that brings those concepts to life. Without considering this reality layer, any debate becomes inherently ineffective.
This reality layer manifests in various ways. It might involve significant overhead that complicates system understanding and maintenance. Or, it could appear as a localized improvement that ultimately degrades the overall system. Furthermore, real-world scenarios often present numerous exceptions, and accommodating these exceptions can dilute the original concept to the point where its appeal diminishes.
In practical software development, choosing a solution that isn’t perfect is often necessary; it simply becomes the best option compared to what other alternatives are available. Context, nuance, and trade-offs are inherent. Abstract discussions rightly omit these complexities to present concepts with maximum clarity. However, code from live applications exposes these elements mercilessly.
Before sharing any code from 37signals, I always seek permission, and the response is consistently an enthusiastic YES, PLEASE. This isn’t surprising, especially considering their public discussions on this very subject a decade ago. I wish more companies would adopt this open approach. I’d appreciate seeing more analyses of design techniques that incorporate real code from actual applications. In essence, I wish more articles facilitated answering the fundamental question:
Compared to what?
Sign up to receive new posts via email, or subscribe to the RSS feed.