http://www.perlmonks.org?node_id=569852

Hi All

I need the wealth of your wisdom and experience in software development, so this is not related to Perl per se. Hence 'OT' in the subject. The software that I've been working on for the past 2.5 years has become so hard to optimise and modified. We had a meeting last week and we decided to re-architect it.

The basic problem is that the software is written as one monolithic mod_perl application, which appears to be three different products to the client. To be able to go forward, we need to do deep surgery on it and split it to different independent sub-systems and layers. We also need to majorly change the database structure. Although we might be able to reuse the existing modules, I am sure that the new architecture will be completely different from now.

This brings me to question, "HOW are we gonna do it?" There are two options: First is to Rewrite, and second is to Refactor. I'll list the good and the bad of each approach from my point of view. Then I'd like to hear what y'all have experienced when facing problems like this.

Rewrite

My definition of Rewrite is to create the new architecture and then copy the relevant modules from the old code base with probably some modifications to fit the module with the new architecture. So this is not a complete rewrite, but this is not a refactoring either.

The good

  • We can start from a clean state, which doesn't carry baggages from the old architecture.

The bad

  • We may miss some functionalities from the old system while porting the modules.
  • The old code base could have been changed while we're working on the new code, which makes a porting nightmare.
  • The new code base isn't tested to handle the load of the production code, which mean we'll have performance problem on the first few months after launching the new code.

Refactor

My definition of Refactor is to change the code one thing at a time, whithout affecting functionality.

The good

  • Less likely to miss functionalities from the old code base.
  • The original code has already been tested on production.

The bad

  • We might not end up with the new ideal architecture, because refactoring works on the code level, not on architectural level.

I haven't made up my mind on either approach. And due to my limited experience, I can't get a more exhaustive list of the good and the bad of them. Can you help?

Thank you

UPDATE: Thanks for everyone who've provided their insights. More insights are welcome. Up to this minute the best insight is from GrandFather, which suggested to refactor by creating interfaces and test suites.

UPDATE: Strangler Application pointed by adrianh seems to be the technique that incorporate interfaces mentioned by GrandFather. Great suggestions guys!!! Keep it coming.

-cheepy-