The best code is the code you don’t write. The second best is code that’s obvious.
I’ve been thinking about this a lot lately. Early in my career, I was proud of clever solutions. Now I’m proud when someone reads my code and says “that’s it?”
A few principles I try to follow:
- Delete before you add. Can you solve the problem by removing something?
- Boring is good. Use the obvious pattern. Save creativity for the problem domain.
- Optimize for reading. Code is read 10x more than it’s written.
None of this is original. But it’s easy to forget when you’re deep in a problem.