3 ms·
"1. Write code that you think is almost trivial. That way it is simple enough to debug. If you think your implementation gives you bragging rights down the pub,
by dllthomas 14y ago
"1. Write code that you think is almost trivial. That way it is simple enough to debug. If you think your implementation gives you bragging rights down the pub, its waaaaay too complicated"
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." --Brian Kernighan
That said, sometimes cleverness is necessary, or actually serves the goals of making things testable and debuggable.
"2. log everything, write tools to parse the logs. All this turning logging off / on / up / down. It's disk space, its cheap and trust me when you wanted -vvv debugging, the live server was set to -q"
While I tend to agree, it's not (just) disk space - it's IO, which sometimes isn't cheap.
- lifeisstillgood 14y agoYeah I could not remember who said the Kernighan quote. Should have remembered. I am not against cleverness, just appropriate for the system - for example some part of the system needs to be very clever else its a pretty mind-numbing project. However the rest of the project should be less clever.
- dllthomas 14y agoRight, any cleverness should be buying you something worth it.