Cluttered code (almost complete): refactor it now or later?

I have very cluttered code and the current revision is almost complete, which means all the functionality I wanted for this version / sprint is getting executed.
Should I end this revision as it is and refactor it later, or should I refactor it right now?

+2


a source to share


7 replies


There is no "right" answer for this, is it really a matter of priorities?

  • Does the code work?
  • How well does it work?
  • Are there deadlines?
  • Is release more important than quality?


You must consider all of these issues together. I usually find that refactoring can, especially in large projects, be a lot more time and effort than you think it can be. You can also break things down (this is where unit tests are amazingly useful).

I will usually aim to release commercial projects and then refactor unless there are major issues with the existing code.

+5


a source


Refactoring now. Especially if you have debugging ahead.



+4


a source


If you are coding for a / api condition that is stable, there is no reason not to refactor now if you have time.

If api / requirements are a moving target, refactoring or not will be a situational and subjective decision.

BUT.....

If you haven't already, write tests that provide broad coverage before refactoring.

I cannot stress this enough.

+3


a source


If you're on a deadline and something is coming soon, it probably isn't a good idea to really make some major changes. If you think cleanup is manageable, go for it. I would recommend that you fork your current codebase and refactor there. Then drain it back. Or you can use a branch as your release branch and refactor in the trunk. The longer it clutters up, the harder it will be to maintain it, so do it sooner rather than later if you deem necessary.

+2


a source


If the question is about making something easy to manage and use, and the question is "now or later," the answer is always NOW.

Projects that are "nearly complete" tend to take longer than expected.

Remember: the first 90% of the code is the first 90% of the time, the last 10% of the code is the last 90% of the time. =)

+2


a source


Refactor as part of your implementation. Have complete unit tests so you can refactor without introducing defects.

+2


a source


Refactoring now. Mixed refactoring is complex refactoring. The code is fresh in your mind today and unfinished by tomorrow's changes; it is ripe for refactoring ever. Mature, but not yet rotten.

+1


a source







All Articles