The rewriting trap…

I cannot count the number of times I have heard this phrase by a fellow developer “The component XYZ is an absolutely stinkin pile of %&^&*#, we need to rewrite the whole thing”. Actually I remember saying it once or twice myself. Probably in very rare cases this might hold true, but in most cases rewriting the whole thing would end being the wrong path to choose. It reminds me of the problem Netscape folks had faced a long long time ago…

When a component is developed, it has undergone many cycles of iterations, some demonstrations with clients. And needless to say, thousands of bugs that were reported over the period. (I say thousands because my current project JIRA count has crossed it way long ago.) So we have this old guy settled in its position for a long time and has grown many “things” around it so it looks hideous. But there is another word to explain this, matured! Rewriting this whole thing might make the code cleaner (which is a very subjective term anyways), but to get the component where it is not with clean code, that most probably would not be a trivial task. And not worth it too. As a proud member of the developer species, I do feel the yucky feeling when I see bad code smells all over the code base. But just dumping the whole thing and rewriting from scratch is almost never a wise option.

The only way to move in the right direction is Refactor. Before which, have strong unit tests for the component so that changing things around is a safe game.

Abhang Rane


No comments :

Post a Comment

Leave a Comment...