3 ms·
Just as "the best writing is re-writing", the best coding is re-coding or re-factoring. I find that to get things in a workable and maintainable state, I need t
by akg 15y ago
Just as "the best writing is re-writing", the best coding is re-coding or re-factoring. I find that to get things in a workable and maintainable state, I need to write something about 3 times. The first pass is usually a hack that fixes the problem at hand. The second pass is used for a little bit of code cleanup and fixing corner test-cases. The third pass is the major re-factor such that the code is maintainable and fits in with the rest of the software design.
Having worked with extremely large code bases, I can say that the practice of re-factoring goes a long way. The initial time investment seems excessive, but it pays significant long-term dividends when it comes to maintenance. Not only is it easier to extend the solution but also fix bugs and supply patches. Furthermore, clean code (not just syntactically) is easier to understand by others.
Writing clean code is possible, it just takes a bit of discipline to go back and re-write. I've only worked with a handful of people who did this, but their code was the most elegant I've seen, easy to work with, and widely applicable.