The best code isn’t code that’s elegant or code that’s brilliant it’s code that doesn’t need to be written. One of the best feelings is when you can take a new problem and turn it into an existing problem that already has a solution. Sometimes that requires making a few tweaks and compromises to the problem or the code but the time and effort saved can be massive. This requires a deep understanding of the problem being solved as well as the existing code. Someone knowing the code but not the problem won’t be able to transform the problem into something applicable. And someone having a deep knowledge of the problem but not the code won’t be able to see how the code can be adapted to solve this scenario. The optimal result comes from someone who can strip away the cruft from both of them while still maintaining the spirit of both in order to combine them.

To make this work you need code that’s clean, well architected, and accessible. Such code is a pleasure to work with and is transparent enough that a decent programmer can see how it can be tweaked to solve new problems that arise. This requires massive amounts of discipline to go back and refactor your code when necessary to keep it in a pristine state so it can be easily transformed when needed. And that transformation with introduce wrinkles that will need to be ironed out to set it up for the next wave of changes.

While writing this post I was reminded of a joke that emphasises this idea of minimizing work by focusing on what you’ve already done:

A mathematician was interviewing for a job. The interviewer asks him - "You are walking towards your office and running late for a very important meeting and you glimpse a building on fire with people screaming for help. What will you do?". The mathematician thinks for a while and replies : "People's lives are more important than an office meeting. I would immediately call for a fire brigade and help the trapped to the best of my abilities". The interviewer seems to be impressed with the mathematician's answer and moves on to the last question. Just to check his sanity, she asks: "And what if the building is not on fire?" After a moment of thought, the mathematician replies with confidence: "I will set the building on fire. Now, I have reduced it to a problem that I have already solved before!"

- ScottElliot on reddit

Read more!