3 ms·
This is so true, but so shallow too. I think the big mistake is to treat the code as "the main thing" when in reality it's just a model (a golem) mimicking some
by random3 6y ago
This is so true, but so shallow too.
I think the big mistake is to treat the code as "the main thing" when in reality it's just a model (a golem) mimicking some "other thing"
We're missing an entire set of code characterizations. Yes we have a "pattern language" but there's not much to characterize it structurally wrt "code distance" from one part of the code to the other (e.g. in call stack depth as well as in breadth).
And again all of this needs to happen wrt the "abstraction" not the code itself.
Having 10 methods 90% duplicated in a single file with 10% pecent difference is many times better than trying to abstract it.
Having the same "unit conversion" function duplicated in 3 parts of the code can be disastrous.
These two examples are very easy to see and understand, but in reality you're always in a continuous state in between. And "code smells" like passing too many parameters or doing "blast radius" for certain code changes are only watching for side-effects of a missing "code theory". An interesting book on the topic is "Your code as a crime scene".
The bottom line is we're trying to fix these problems over and over again without having a good understanding of what the real problem is and this leads to too many rules too easy to misinterpret unless you are already a "senior artist"
- ijidak 6y ago> Having the same "unit conversion" function duplicated in 3 parts of the code can be disastrous. This. I feel like it's really about cognitive load to remember and recognize the differences. Duplication in 3 distant files, places a heavy load on the developer to: 1. Discover the duplication 2. To grasp the reason for the differences in the 3 different locations. 3. Remember these things Whereas when the duplication is in the SAME file, #1, #2, and #3 can become very manageable cognitively. Now the question changes to.. Is the cognitive load of dealing with the different special cases in a single de-duplicated method GREATER than simply leaving them in separate methods? Often the answer is duplication WITHIN a file is less of a cognitive load. Whereas duplication ACROSS files is a heavy cognitive load. Minimizing cognitive load minimizes mistakes. And minimizes developer fatigue. Thus boosting productivity. At least, that's my development philosophy, even though I've never seen it in a design pattern or a book. It just seems to make sense.