Excerpts from Janelle Klein's message of 2015-01-22 14:52:10 -0600:
>
> You could make similar arguments about pretty much any design principle...
>
> For example, following the DRY principle has certainly lead to way overly
> complex solutions for the benefit of removing duplication. Duplicating
> code has consequences. Removing the duplication has consequences. We have
> to use our brains to evaluate the trade-offs and ultimately optimize for
> human factors.
>
> That doesn't make DRY a bad principle, it's quite useful. Design
> principles are not a substitution for thought.
I thought about this off and on. I'm definitely all for thought as the
backbone for any rigorous application. So here's my thoughts. . .
What I'd like to avoid is a sense of relativity completely subject to the whim
of context. I think we end up with this trap with "context is king" or "the
right tool for the job" arguments.
So I'd like to see if we can determine that modularity is universally good in
all contexts, which is really all the SOLID principles are advocating (through
the lens I talked about in my earlier post).
This is different from DRY, which I don't think is universally good. DRY leads
to coupling -- possibly to systems which are not modular. And coupling to
anti-modular systems is often terrible. This is incidentally why Bob
originally had principles that were sensitive to afferent and efferent
coupling. These kinds of principles seem to take the cynical stance that we
will never get modularity right. But this is why parametricity is so
interesting to me.
So I'm open to being proven wrong, or reshaping this statement. But I can't at
all justify jumbling multiple responsibilities into one module. Nor can I
justify solutions that require opening up modules by design. I certainly will
/never/ allow for someone using subtyping to break the substitution principle
-- that's a tragic flaw that betrays the very point of subtyping. Anyway, you
all probably the point.
As a small addendum, it feels very weird for me to be defending SOLID. SOLID
carries with it the weight of an OO culture, and I find it liberating to just
talk about modularity clearly without the acronym. But since I do genuinely
think there's universal value to the principles, I'm not willing to convert the
universal quantification to an existential one.
-Sukant