DCSIMG
If it is Working Don’t Touch it? - Gil Fink's Blog

Gil Fink's Blog

Fink about IT

News

Microsoft MVP

My Facebook Profile My Twitter Profile My Linkedin Profile

Locations of visitors to this page

Creative Commons License

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.
© Copyright 2013 Gil Fink

Hebrew Articles

Index Pages

My OSS Projects

English Articles

If it is Working Don’t Touch it?

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

Comments

Bharath Kuppuswamy said:

True... Every code has to be unit tested.

# September 9, 2009 11:10 PM

Jose Fernandez said:

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 :)

# September 9, 2009 11:22 PM

Giorgio Sironi said:

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

# September 10, 2009 12:35 AM

steven said:

"So the lesson here is – if it is working and smells touch it!"

and touch it with tests first!

# September 10, 2009 1:09 AM

fel said:

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

# September 10, 2009 9:34 AM

Gil Fink said:

@fel,

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.

# September 10, 2009 12:37 PM