3 ms·
When we are writing a comment for a function we are repeating ourselves. We are transgressing the DRY (Don’t Repeat Yourself) principle. Agreed, but this only
by opminion 13y ago
When we are writing a comment for a function we are repeating ourselves. We are transgressing the DRY (Don’t Repeat Yourself) principle.
Agreed, but this only applies when code is meant to change. It has been pointed out (perhaps by Knuth on Literate Programming) that a good way of explaining something to another person is to do it in two different ways (comment and code), which is practical when code does not change.
The follow-up question is why does our code have to change so much. We use toolboxes (IDEs, compilers, version control) optimised for change management. Would it be possible to treat our code like the Clojure/Datomic crowd treat immutable data structures?
- RyanZAG 13y agoIt has to change because our code is not the ends itself, but only a means to an end. The end itself is using rooted in human psychology - 'ease of use', 'problem solving', etc. This means that the end itself cannot ever be truly completed as it's about as close to a random process as you can find. This means that the code itself will have to continue to change to follow the random process it is trying to arrive at. Simply: the environment the code is executed in changes, and so the code must change.