If it is Working Don’t Touch it?

September 7, 2009


If it is Working Don’t Touch it?

Occasionally I hear this sentence from here and there.
Every time I hear it I get angry again. IMHO, when someone says that sentence
it’s probably indicating that there is a lot of pain coming at us in the future.
When I always hear that sentence?

  • When there is a spaghetti code that nobody knows how to deal with (because
    the code is so tangled).
  • When the developer is lazy and don’t want to change something that is
    working even though it is badly written.
  • When there are no unit tests that will imply that changes you made broke
    the application.
  • When managers/developers want fast delivery and don’t care about code quality.
  • When no one knows what is going on in some piece of code (or don’t care).
  • And more. You name it.

Even though it is probably implies that I’m always touching the code and change it,
this is not the case. What I want to say is that code changes during the development
and maintenance cycles. You need to refactor smelling code even though it’s working and
not keep bad code. If you have poor design or spaghetti code it will come at you in the
future and then to refactor the code will be horror. So if you see something that isn’t
right it’s your responsibility to fix it or at least to report about it.
For example, last week I showed a piece of code that I wrote to other colleague.
During our conversation I saw a method that was bad written and fixed it.
Since I had unit tests for my code I could see that my changes didn’t break the application
and now it’s running faster.
So the lesson here is – if it is working and smells touch it!

DotNetKicks Image
Add comment
facebook linkedin twitter email

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>



  1. Bharath KuppuswamySeptember 9, 2009 ב 23:10

    True… Every code has to be unit tested.

  2. Jose FernandezSeptember 9, 2009 ב 23:22

    I agree with your conclusion, but it’s not quite that simple.

    I found a horrible smell in an old part of the code while finishing up a recent build, but I had to leave it alone, because:

    – no time to make the changes due to a strict release date
    – no time budgeted for QA to test the changes, which were outside of the build scope
    – no unit tests in place to make sure the changes wouldn’t break existing code

    We can’t always fix smells when we want to 🙂

  3. Giorgio SironiSeptember 10, 2009 ב 0:35

    Many legacy applications are written without any sort of automatic test… This is the most important fallacy that leads to this maxim.

  4. stevenSeptember 10, 2009 ב 1:09

    “So the lesson here is – if it is working and smells touch it!”
    and touch it with tests first!

  5. felSeptember 10, 2009 ב 9:34

    If it’s working it’s done. If it’s done why are you working on it?

  6. Gil FinkSeptember 10, 2009 ב 12:37

    If it is working doesn’t mean that it is working as expected with a well design or with good performance which means that it isn’t done at all (sometimes). It means that what you have done is just working.