Perspectives from the *other side* on Software, Management and Life

Saturday, December 25, 2010

To Write or to Rewrite

Anyone who has ever managed engineers would know how most love a clean slate. Its natural to want and yearn for a clean canvas where the engineer can let loose their 'creativity' and 'architecture' sense.

That stated, most real world problems require adding to an existing structure. For software engineers, that means working with an existing and typically significant codebase that may crumble if not handled correctly when adding functionality.

I've seen software engineers attempt whole re-writes just to avoid reviewing existing codebase and its associated delicate handling. The question being when is a rewrite justified, and my rule of thumb is:

Do Rewrite: Existing code is in a technology that is outdated, or is written in spagetti code, or has Systemic issues (security, scalability, performance etc). All of these stated classifications must also meet the criteria that any enhancement or fix done on top of the existing code will require more time than the rewrite. The enhancement can be the specific task or group of tasks in the roadmap.

Dont Rewrite: Existing code is more or less feature complete with possibly a few glitches.

The reason to avoid a rewrite as much as possible is that code generally evolves from its original specifications, and while attempting a rewrite a lot of unwritten specifications are overlooked thereby arriving at a rewrite that is functionally less mature as well as possibly suffering the same issues that exist in the older code.

An interesting experience I had recently around this subject was with my ATS (Auto Transfer Switch). The picture of which is above. The Magnetic Connector got worn down and I asked a electrician to replace the specific component. He stared at the circuit for 15 minutes and then prescribed that he needed to completely rewire everything (and will obviously charge me for it!). On my insistance that only one component is broken, and he just needs to make sure the replaced component is installed correctly, he refused to take on the project since he had no idea of the circuit. It was obvious to me the electrician was more a creature of habit and preferred to work on circuits created by him so as to avoid having to use diagnostic tools to determine where the '0's and '1's are. I knew he'd create a similar layout and then I'd have the same problem if I ever called in a different electrician with similar traits. So I stared at the circuit for about 60 minutes after he left and it finally made enough sense for me to do the replacement (which was a 10 minute task!)


Blogger anonymous said...

keep it up

1:55 AM


Post a Comment

<< Home