CGI Development - Multiple Entry or Dispatch

Paul Fenwick pjf at
Sun Nov 3 21:51:24 CST 2002

G'day Scotty / Melb.PM,

	Golly, my answer to this question is a great big "it depends".
If the project involves mod_perl or CGI::Fast, then the dispatch
mechansim as some obvious advantages.  Modules only need to be
loaded once, a single database connection can be used, and data
can be cached between requests.

	Of course, if your various functions have little overlap
with each other, then you may only have a negligible speed saving
from using dispatch vs multiple methods.  Outside of a mod_perl/fastcgi
environment, dispatch becomes slower as there's more code to
load in and parse.

	At the end of the day, unless one method gives you a
*significant* saving or advantage over the other, then I can't
say I have an opinion either way.  I've personally used both
methodologies, and continue to do so.  Usually I'm aiming for
whichever approach gives the most clean, maintainable, and efficient
code.  Most of the time I use both methods -- dispatch for
closely related features, and multiple entry for widely
separated ones.

	All the best,


Paul Fenwick <pjf at> |
Director of Training                   | Ph:  +61 3 9354 6001
Perl Training Australia                | Fax: +61 3 9354 2681

More information about the Melbourne-pm mailing list