3 ms·
I prefer compact coding (started with BASIC on a Tandy 102 laptop way way way back). But it also needs to be readable/pronounceable: and it needs to be readabl
by warrenm 9y ago
I prefer compact coding (started with BASIC on a Tandy 102 laptop way way way back).
But it also needs to be readable/pronounceable: and it needs to be readable even on cruddy screens / bad printouts. No "i" and "j" for loop counters, for example: the compiler doesn't care how long you make your names, so I use things like "kt" or "ndx" (because typos happen, and fewer characters that still convey the same meaning is acceptable).
I also do my best to never write overly clever code. Shared another [HN](https://blogs.msdn.microsoft.com/oldnewthing/20170719-00/?p=96645 https://blogs.msdn.microsoft.com/oldnewthing/20170719-00/?p=...) [post](https://news.ycombinator.com/item?id=14810014 https://news.ycombinator.com/item?id=14810014) with a little commentary on G+ last night:
Sadly - or, perhaps, happily - I can remember when I used to do wonky crap like this.
Then I learned the axiom, "if you code as cleverly as you can, you are, by definition, not clever enough to debug it" (I think it's called Kernaghan's Lever - but I may be mistaken).
Write code you can explain to a 4th grader. Or your grandma. If you have to stop and think about how clever it is, you are going to end up cleavering yourself with your feigned cleverness.