Hacker News new | ask | show | jobs
by Jtsummers 1615 days ago
That's actually more or less how DRY is described in The Pragmatic Programmer (20th anniversary edition):

> Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

Further on:

> Dry is about the duplication of knowledge, of intent. It's about expressing the same thing in two different places, possibly in two totally different ways. [emphasis in original]

And the next paragraph:

> Here's the acid test: when some single facet of the code has to change, do you find yourself making that change in multiple places, and in multiple different formats? Do you have to change code and documentation, or a database schema and a structure that holds it, or...? If so, your code isn't DRY.

1 comments

Early in my career, a co-worker and I developed the habit, when a bug was fixed, of asking each other "Did you fix it everywhere?"

But that's the problem right there. Why is there more than one place to fix it?

(Now, sure, if you're using a function call wrong, you need to fix it everywhere you call that function, and it's fine that there are multiple such places. That's what functions are for. But if it's something like how a value is calculated... why is there more than one place that calculates the value?)