Ovid has asked for the wisdom of the Perl Monks concerning the following question:
I have been tasked with overseeing the rewrite a very large Web-based application. This application was written before I started working here and I’m not terribly familiar with it. I’ve reviewed some of the code and it is terrible. Some issues:
- Extensive use of globals shared across multiple programs.
- Often fails to check status of system calls.
- strict is not consistently used.
- No documentation.
- Extensive HERE documents.
- A in-house routine to parse-form data was used, but was converted to CGI.pm, yet retained the old interface which often discarded data.
- Many duplicate functions, but often different interfaces to them.
- Many code features have side effects (such as changing those #$@%! gloval vars!).
This is a far more serious task than I have ever undertaken before and I could use all the advice I can get. I have been informed of this just a few minutes ago and here are my rough thoughts on approaching this:
- Create an inventory of all components necessary for this to run.
- Document the inputs, outputs, and purpose of all programs.
- Identify a set of standards for the rewrite. In particular, ensure that functions have standard interfaces (I'm sick of some returning a HoH and others returning a reference to an HoH).
- Identify what logic should be handled by the database and what should be in the Perl code.
- Strip out all HERE docs and start using Template Toolkit.
That's where I get stuck. Should I start working on the modules first? I think that's the best approach. However, do I rewrite them so that they set the globals and return the values, so that old code doesn't break? Simply stripping out globals will break every program. Later, when the conversions done, strip out the 'globals' code? I don't like that as I'm leery that the "stripping" out won't be done.
Start porting this application to a test site and build it a piece at a time? That's my preference, but it does mean that we won't have the more robust features available during development.
This is -- for me -- a very large rewrite. It's only about 30 or so programs, as far as I can tell, but many of them are thousands of lines long (though that's due in part to the HERE docs. Am I looking at this the wrong way? Is there a better way I can organize and direct things to get this done? Further, we're not being paid for the rewrite, so this will be done part-time in addition to our other work.
Cheers,
Ovid
Vote for paco!
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.