Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

When is it worth it to move to a Framework?

by gwhite (Friar)
on Oct 14, 2010 at 18:54 UTC ( #865333=perlquestion: print w/ replies, xml ) Need Help??
gwhite has asked for the wisdom of the Perl Monks concerning the following question:

I have a twelve year old cross platform CGI application that I produce for 20-30 new clients every year. It uses a good amount of CPAN from a big rewrite in 2002-2003, DBI, CGI, Text::Template, etc. and a bunch of my code that does what it does. My parts of it are around 7,000 lines of code. In the next few months, I am going to internationalize the application and do my standard round of improvements and tweaks that I do every year.

That being said, is it time to look at moving to a standard framework, such as CGI::Application, Catalyst or one of the other pieces of work? If I were starting from scratch, I would certainly be looking at one of these, but I'm not starting from scratch. None of the frameworks seem to support Text::Template and I have about 300 templates done in a Text::Template format. Would adding a plugin/hook to this be terribly complicated or defeating the whole purpose of a standardized framework? I am trying to decide if the reason to move is just being a cool kid that uses a spiffy framework, or could this actually make my life easier if I continue to produce this app for another 12 years.

I still write about 30-40% of the code, but use contractors to do the rest and they have to "learn" how the whole thing goes together each time I bring a new one into the loop. Even with moving to a framework I am not sure that this won't still be the case.

Can anyone tell me about their experience porting a big CGI app to a framework? was it worth it? is there anything in this ramble that makes it obvious I should go one way or the other?


Comment on When is it worth it to move to a Framework?
Re: When is it worth it to move to a Framework?
by pileofrogs (Priest) on Oct 14, 2010 at 19:05 UTC

    I think the best way to handle this would be to try making a few test apps in the frameworks you are considering. Then you'd really know what you were getting yourself into.

    I recently did some work with Catalyst, and it really was a whole-new-level of good, over working the old way. It's modularity and flexibility is awesome.

    I would be surprised if you had to build a %100 port, all at once. IE you could probably port some stuff and leave other stuff alone and do it a bit at a time. That may sound crazy, but Catalyst is really that modular and flexible.

    Regarding Text::Template, it should be pretty easy to implement a plugin if there isn't one already. The way things tend to work in Catalyst is, you take a module that does the heavy lifting, like Test::Template, and you write some glue code as an adapter and hey-presto, you've got a Test::Template Catalyst plugin.

    Hope that helps.


Re: When is it worth it to move to a Framework?
by Illuminatus (Curate) on Oct 14, 2010 at 19:51 UTC
    I think your decision really depends more on your current coding practice. If your code is already written in a modular fashion, and changes/features don't often break existing code, then a virtually-complete re-write is probably not worth the effort.


Re: When is it worth it to move to a Framework?
by Your Mother (Canon) on Oct 14, 2010 at 21:24 UTC

    Go to Catalyst! Especially if you have a good test suite already. This is there for you, Catalyst::View::Text::Template (Catalyst is completely agnostic about the pieces it can use and mix and match), and the amount of extras that are there to help are huge.

    It's a pretty steep learning curve at first but it will pay handsomely soon after.

    Strangely enough, I had a CGI that was about 7,000 lines in 2006 which I replaced with a Catalyst app in 3 days; this was after I was pretty handy with the kit already. This was a particularly simple app (just had a lot of parts) so YMMV but Catalyst made makes web development quite rapid once you get the hang of it.

Re: When is it worth it to move to a Framework?
by zby (Vicar) on Oct 15, 2010 at 11:27 UTC
    The recently fashionable option is to write directly to the PSGI API and use the wonderful Plack deployment tools. This would probably require the least changes and still give quite a bit of advantages.
Re: When is it worth it to move to a Framework?
by sundialsvc4 (Monsignor) on Oct 15, 2010 at 14:00 UTC

    It seems to me that the only way to approach this question is to do a cost/benefit and risks analysis ... as thoroughly and methodically as you can.   Select a purely experimental case ... implementing two or three selected screens (or whatever seems to you to be a representative cross-section of the task) in several candidate platforms.   You should be more mindful of, “where does it hurt?,” than of, “where does it stink?”   :-)

    Platforms are a very mixed bag.   They can implement a lot of things very quickly indeed until the proverbial fly lands in the proverbial ointment, and gets stuck there.

Re: When is it worth it to move to a Framework?
by jfraire (Beadle) on Oct 18, 2010 at 04:43 UTC

    I suppose changing to a framework is easier now than it will be one year from now, when you have added more functionality. I think you should be pondering these factors:

    Options to evaluate.
    There are several nice frameworks with different goals and scopes out there. I would think of CGI::Application, Catalyst, Dancer, Mojolicious. I think you should set your list of options to evaluate.
    You are running CGI scripts. There might be an important compile-time penalty for some of the frameworks and you might need to consider going to a persistent environment (mod_perl, FastCGI)
    Provided infrastructure.
    Frameworks often offer some features or infrastructure that you probably already have. For example, session management, authentication and authorization methods, database connectivity. I think these infrastructure is the first thing you will need to migrate as it is needed before your business logic can be implemented. If you are using CPAN modules, chances are Catalyst and CGI::Application have plug-ins for them
    Learning curve and contractor availability.
    It should be wise to go with a framework with a large user base. You could find contractors with less effort, and it should be easier for them to understand your code.

    Having said that, I am partial to CGI::Application. Once you settle your infrastructure needs, it should not be hard to move your business logic into the framework. Because it is quite lightweight, it would not hurt your current performance. And its learning curve is not bad at all.


    Julio Fraire

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://865333]
Approved by superfrink
Front-paged by Corion
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (18)
As of 2014-07-30 13:06 GMT
Find Nodes?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:

    Results (231 votes), past polls