I was looking over the PlanCast events for the week and saw this item. (see my comments below)
One of the biggest unaddressed problems we’ve encountered as an engineering team is: despair.
Despair is when you are fixing a bug and you happen upon the ghetto of your code base. Ill maintained, written a long time ago, duct taped together to just barely work. You go in and are immediately crippled by the state of affairs. The poor code causes you to seize up, incapacitated. How do you go forward?The business still needs the bug fixed. So you carefully tiptoe in, make your fix, and try to leave without touching anything else, fearing any reason to return.
How can you avoid this? How can your code base instill hope? A hope that is the premise of responsible activity, not an empty optimism that the future will necessarily be better than the past.
I can tell you how to get out of this mess, start writing Unit Tests. Unit testing is your friend in this situation. Write testcases for the current code, this may take a long time, once you have done this – and only then – you can start modifying the ghetto of your codebase. The unit tests will help you understand the code, and will give you the possibility to recognize the parts you can easily refactor without breaking too much.
There is no problem with refactoring the same piece of code multiple times as you go along. Deprecating or refactoring the code you just wrote means that you have learned something.