How to restrain one's self from the overwhelming urge to rewrite everything?

Posted by Scott Saad on Stack Overflow See other posts from Stack Overflow or by Scott Saad
Published on 2008-11-27T17:47:49Z Indexed on 2010/05/28 6:31 UTC
Read the original article Hit count: 336

Setup

Have you ever had the experience of going into a piece of code to make a seemingly simple change and then realizing that you've just stepped into a wasteland that deserves some serious attention? This usually gets followed up with an official FREAK OUT moment, where the overwhelming feeling of rewriting everything in sight starts to creep up.

It's important to note that this bad code does not necessarily come from others as it may indeed be something we've written or contributed to in the past.

Problem

It's obvious that there is some serious code rot, horrible architecture, etc. that needs to be dealt with. The real problem, as it relates to this question, is that it's not the right time to rewrite the code. There could be many reasons for this:

  • Currently in the middle of a release cycle, therefore any changes should be minimal.
  • It's 2:00 AM in the morning, and the brain is starting to shut down.
  • It could have seemingly adverse affects on the schedule.
  • The rabbit hole could go much deeper than our eyes are able to see at this time.
  • etc...

Question

So how should we balance the duty of continuously improving the code, while also being a responsible developer? How do we refrain from contributing to the broken window theory, while also being aware of actions and the potential recklessness they may cause?


Update

Great answers! For the most part, there seems to be two schools of thought:

  1. Don't resist the urge as it's a good one to have.
  2. Don't give in to the temptation as it will burn you to the ground.

It would be interesting to know if more people feel any balance exists.

© Stack Overflow or respective owner

Related posts about best-practices

Related posts about subjective