3 ms·
I see similar arguments come up over and over at HN, and I say they stem from a fundamental misunderstanding of DRY. What we must not repeat is not lines of cod
by Ma8ee 6y ago
I see similar arguments come up over and over at HN, and I say they stem from a fundamental misunderstanding of DRY. What we must not repeat is not lines of code, but how we do certain things in the code. That is, it’s fine to repeat syntactically identical sections of code if their semantic meaning is different. But if the semantic meaning is the same, they must never be repeated because we must never have several definitions of the same thing in the same program. This is similar to the concept of normalisations in DBs.
- takeiteasyy 6y agoCould you give an example of syntactically identical sections of code with different semantic meanings?
- Ma8ee 6y agoOnly contrived ones without supplying quite a bit of context.
- hknapp 6y agoy = m * x + b can refer to the distance a car has traveled over time at a fixed speed with a starting point as well as the cost of ordering a certain quantity of an item with a fixed shipping cost that's my best attempt at an example