Over DRY
tl;dr:
Y in DRY is for yourself. Maybe for others. But maybe not.
When DRY is too DRY? DRY principles are now widely adopted in our trade, thanks to Pragmatic Programmer’s undeniable effect, where “Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.”
But, can we go across the board, and from time to time, get too DRY? Don’t freak out: content below maybe shocking for some.
We build code, create objects and methods. We refactor up to the point of perfect distillation, where we obviously applied DRY. We get over excited about some particular approach we put forth to solve a particular problem. We think — hey this is so good I need to share this so that others can benefit from it! So we go ahead and move that piece of code right over, to the core helper library or whatever.
Really? Obviously, we have to have both test and documentation in place. Then, it has to be properly released, along with the management, maintenance, and support that goes with it.
— Hey, I’m having issue with that new set of methods from our core library
— Hum? Which version?
— Well. 1.0.3
— Ah! We’re now at 2.0.0
— Ok but I have a release coming up. Can’t update.
— Got to branch dude. Got to branch…
You know what? That superbe piece of code, not only I don’t want it, but you most likely don’t want to share it, at least yet. Before you move that code to the core, ask yourself, is that real knowhow that is really worth sharing. Go ahead, ask your market for it. Here are 3 potential answers, which are all crucial input (harshness aside)
- “don’t care”
- “nice but you’re reinventing the wheel. Better use Foo library for this.”
- “Cool! Show me some more. Are you blablabla…”
If you get people all excited, then you might be onto something and you should consider getting into an incubation phase, where you polish it a bit, properly add test cases with nice coverage, and document it. What do you have in mind for future contributions? Reflect on it, share your thoughts, and engage in discussions.
And by the way, the Y in DRY is for Yourself.