Many times during our development duties we have to read through code segments to figure out the desired intent of a feature. Today I was doing just this. There is a new feature that I need to implement and to do so, I needed to walk through a bunch of code to determine where my changes may need to go.
Along the way looking though the code I found some less than efficient code (no, this is not a rant about WTF style code). This code was doing stuff like checking the count of an array to ensure it was > 0 before it went into a for-each loop, along with some other useless stuff.
I made note of the code, but did not change it and I continued on my marry way. Once I figured out where I needed to make my changes I went back to that code. My original intent was to fix the code in which I found to be less than efficient. But then I stopped, I did NOT make the changes. Why you may ask, here is why
- My tasks was NOT to change/modify/refactor the code in this giving class
Changing this code would be a waste, my task was to do something else. If I feel this code needed to be changed, I need to add it to the list for future work.
- There are NO tests for this project so I could not assume my trivial changes would not break everything.
It sucks having no tests and with the absence of test, I would not have felt comfortable changing this code without putting it though its paces and like I said before my task was not to fix this code, but to add a new feature.
- Why change code that works just fine and is not causing bugs, simply because I feel it was less then efficient?
As much as I don't like inefficient code, I have a hard time making changes to it if there is no real business sense. Sure if it was running too slow, or chewing up memory I would make the change, but these are not doing that.
Anyway, I just always feel dirty when I come across code that needs to be fixed and I am not in the position to fix it. Oh well, I am off to take a shower to get rid of that dirty feeling.
Till next time,
01-08-2008 12:14 PM