Written by Michael Pratt - Inspired by The Codeless Code
These aren't rules, merely guidelines. The order isn't meant to imply a ranking of importance. Some conflict with each other - this is not a defect, but a reminder that developers often have conflicting requirements. It is up to you to determine how to compromise.
- Minimize magic.
- A clever solution is not always a good one.
- A popular solution is not always the best one.
- The ideal solution is not always worth the effort.
- If something seems hard, make sure you aren't doing it wrong.
- Short, clear code hides fewer bugs.
- A non-functional line of code is a bug waiting to happen.
- Keep code golf out of production.
- Copying is not a substitute for understanding.
- Bugs and limitations in third-party code are still your problem.
- Mastery comes not from knowing how to use a tool, but when and why.
- Reusable code is better than duplicated code.
- Be nice to your future self; write simple and obvious code.
- Even simple code does not self document.
- If you really need to comment every line, your code is too complicated.
- There are only three numbers: 0, 1, and N.
- Don't let progress get in the way of process.
- Deployment automation is great, but don’t become complacent.
- What code style you follow for a project isn't as important as simply following one.
- Don’t suggest a change to the style guidelines unless you’re prepared to implement it.
- You are not the technologies you use.
- If it’s an important project, use a technology you know well.
- Your design should be flexible, but you should still think it out in full.
- "Design twice, develop once” doesn’t generally work out in practice.
- Rewrites can be costly, but they are easier done earlier.
- Be prepared to defend your coding decisions. If you can’t, you should have done it differently.
- Be willing to question others’ code. If you won't, you shouldn’t be reviewing it.
- Don’t take code reviews personally. No one is perfect.
- Seniority, wisdom, and age are not strongly correlated.
- A dozen mistakes, once each, is learning. The same mistake, a dozen times, is failure to learn.
- You cannot measure the value of a developer solely by analyzing the code they write.
- Don’t code around problems to hide them.
- Fix your own bugs and you’re less likely to repeat them.
- New bugs should result in new tests.
- Fixing a bug and ending up with two new bugs means you probably had three bugs to begin with.
- Eliminate suspected race conditions. Don’t wait for a bug to appear.
- Even test code can have bugs.
- Intermittent test failures means there is a bug in the test.
- If your tests fail, your build should fail.
- 100% code coverage isn't always feasible, but more coverage is still always better.
- Good code coverage is not neccesarily indicative of good testing.
- Caffeine is a poor substitute for sleep.