Friday, May 15, 2009

Despite what I've written so far, my first impulse when maintaining code written by other people is not to rewrite it. My preference is to work within the design evident in the code to extend it as needed. That is, if I have enough time and interest to understand the design of the code. One thing I really like about source control is that looking at the history of the changes often helps in understanding the code.

Sometimes I'm not given enough time to understand the design, or the code is just too gross for me to want to figure it out. In those cases, I generally stick in some hack. If I didn't understand the code, the hack could have other problems, though.

The general culture of conservatism with respect to code changes where I work also encourages minimizing code changes, rather than rewriting things.

However, if I have to fix something too many times and the code is too crappy, I'll rewrite it, even if I get chewed out for making changes that are too extensive.

No comments:

Post a Comment