4 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
by lifeisstillgood 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
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
3. testable code - oh yes, yes, yes. Functions that return common structures that are then sent on not wrapped up for that one specific use you had in mind(my most common crime) . But make it simple. If you cannot throw in a config file and run it there on the command line, then its hopeless. Stubs, dependancy injection - I get it, I just want to avoid it.
4. Don't do as I do, do as I say :-)
- 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.
- peter_l_downs 14y ago1. 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 One of my colleagues is a fantastic programmer. Like anyone else he'll occasionally suggest stuff that won't work, but you can tell he's come up with something great when he starts out with "I understand this is trivial, and the stupidest implementation possible, but..." Those ideas have led to some of the most maintainable and debuggable code in our repo.