3 ms·
First, I am not at all contradicting this. :) I just want to get that out of the way. I have found it pedagogical to read some more difficult programs, witho
by taeric 9y ago
First, I am not at all contradicting this. :) I just want to get that out of the way.
I have found it pedagogical to read some more difficult programs, without trying to find ways to make them necessarily "read" better. In particular, generic and/or high performance versions of algorithms.
To your point, this is precisely why I will refuse to generalize some parts of my code on the first pass. First, solve my problem specifically, then try and generalize. (This is not a waterfall style approach, but I do try and keep it somewhat phased.)
- nottorp 9y agoIMO don't generalize unless you find out later you need the same algorithm somewhere else. Otherwise, just leave the specific version in and stick some info in the comments (like a link to the high level description of the algorithm, if it's a common one that has a name, plus some pointers to your specifics).
- taeric 9y agoCompletely agreed. I do recommend playing with it (in like a repl or some other place) to see if you can possibly improve the algorithm, but have specific metrics for what an improvement would be. I'm reminded of a section in Programming Pearls where they explore several versions of a function, each time improving it. Too often I'm impatient and want the final solution first.