Manifesto
Table of contents
Leave no broken windows
If something is trivially fixable, there is no point in creating a separate issue for it to fix it later. Use your judgement: if it is clearly wrong, fix it, add a test case and move on.
Pride and responsibility
You are responsible for the code you write and you should take pride in it. This means that the code should be easy for another developer to read and understand. Extensive documentation is not typically required, instead, use of logical names for functions, filenames and classes is required. Adherence to the Single-responsibility principle gets you 90%1 of the way there.
The cost of a bug could exponentially increase the longer it exists 2
Spotting a bug and fixing it early on can save everyone tons of work down the line. A bug in a persistence layer could mean you have to do a whole heap of trickery, special conditions, upgrade scripts etc. to fix it later on.
Good code coverage is essential, beware Goodhart’s Law 3
To achieve 100% code coverage is a false economy. Moreso, Goodhart’s law paraphrased: “When a measure becomes a target, it ceases to be a good measure”.
Never rewrite code 4
Why? You’re going to make the same mistakes again, or repeat the mistakes of the previous person. It’s harder to write code than read it, period.
No code is the best code 5
The best code is the one which was never written. It has no bugs, it needs no maintenance, no code review, no testing, just nothing. It can’t break existing code and it does not break on software updates. It’s perfect. Whenever you can persuade your manager that the code is not needed — do that. The feature is not needed with a high probability. Moreover — delete the code which is not needed: dead code, commented out code, features which are not in use, flaky or forever ignored unit tests. The less code — the better. No code is the best.
If you need code, try not to write it 5
Find out if the code has already been written for you. It may be in the code base but it could also be another library. Be careful of Not Invented Here syndrome. Evaluate pre-existing libraries for their suitability. There are BAD libraries out there in the wild, but lots of them are excellent. Contributing missing features where required is encouraged. It will still be faster than writing everything from scratch. You will probably not write a better one (quickly).
Automate everything 5
Computers are great at doing the same thing over and over again, humans are not. Humans make mistakes all the time. Repetition/Repeatability is crucial: write the code once, execute it hunderds (millions) of times.