Rewriting an old webapp

rats on 2005-02-21T06:40:44

Client wants me to rewrite/cleanup/extend a webapp written in Perl a couple of years ago by another developer. Almost no use of CPAN modules and HTML is embedded in code i.e. almost impossible to change. And it appears original developer didn't know or want to use OO-Perl which makes extensibility very difficult (for me anyway). Client also wants to use app for another website so stylesheets would be useful.

Obviously I'm replacing everything I can with CPAN modules. Spent some time trying to decide which framework to use. Looked at Maypole and Catalyst but didn't feel confident enough to use in production. Looked at Mason which I've used before for production app but found embedded HTML too messy. Even looked at AxKit which I've used for my own apps before. But client doesn't run mod_perl and website is very low traffic so unlikely in the future. So this pretty well made CGI::Application the way to go. Plus I like the clean separation of code and HTML templates. I looked at Template::Toolkit for a very long time but eventually decided TT is overkill for simple web pages client wants.

I discovered large chunks of obscure (to me) code which I eventually realised was all about session handling. Replaced it all with the single line 'CGI::Application::Plugin::Session'.

Interesting how much my Perl style has changed in the last few years. Found myself replacing C-style for-loops with more compact Perl list operators (e.g. map, grep) just so I could understand what the original code was trying to do. This allowed me to reduce a couple of 100-line subroutines to 10-line ones and then to realise two of them were duplicates so threw one away.

At this stage I have a working version of original app. Now to add the new stuff...