4 ms·
From the Pragmatic Programmer (coined/popularized the term DRY): "Every piece of knowledge must have a single, unambiguous, authoritative representation within
by dgb23 5y ago
From the Pragmatic Programmer (coined/popularized the term DRY):
"Every piece of knowledge must have a single, unambiguous, authoritative representation within a system"
To contrast: Data especially can be very repetitive, say you have a bunch of configurations of somewhat similar things, or you have records that represent purchases at a given time of a thing by someone, they will tend to look very similar, maybe even almost the same
DRY is not about reducing this kind of repetition, because this is just like it should be. Sure, you might want to generate/automate repetitive things or compress them into something more readable and so on, but that's not what DRY is about.
Ultimately it is a form of normalization and decoupling. Ideally you want your code to be in a state so when you change things there is as little coordination required as possible.
- cestith 5y agoDRY really isn't about compressing the data on which your code operates. It's about reducing the number of times your code coordinates the same knowledge about those operations across its text. If you add a field to a record and have to edit the code more than a couple of places to deal with that, you're repeating yourself. If you repeat yourself, those different parts of the code are not only more work to understand and to change, but are more likely to diverge from one another as they are edited in slightly different directions.
- anamax 5y ago> Ultimately it is a form of normalization Yes! Every piece of information that is in two or more places is wrong in at least one of them. That's as true of code as it is of data.