perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steven Lembark <>
Subject Re: OOP or functional?
Date Sat, 02 Apr 2005 18:55:45 GMT

-- Octavian Rasnita <>

> Hi,
> As a general idea, what way do you suggest to create the modules that will
> be used with mod_perl?
> Using the functional style (with the Exporter module), or using the object
> oriented style?
> I am asking this because I want to maximize the speed of the execution,
> and I know that the OOP way might be slower.

Carefully designed OOP will be have no discernable speed
difference on a website (data transmission will dwarf any
of the hash lookups used to find methods).

That said, if all you do is push the data into a hash,
bless it, and an "object" you'll probably be disappointed.

OO in general is useful when the code can be made clean,
compact, and re-usable by having the object maintain an
appropriate amount of state/data and push some of the
messier, repetative code into the object's space. In this
case you can get performance improvements from OO since
the methods can access the object for state information
that otherwise would have to be re-checked at every step.

Frankly, you're probably better off being really careful
about writing maintainable than "fast" code: the eventual
speed cost of hacks to later generations will likely
overrun any speed advantage you get out of cute tricks
today. You'll also find that any downtime from bug hunts
will far outweight the speed gains over the lifetime of
a project.

Net result is that careful OO is generally worth it, but
that means sitting down and asking yourself how the thing
really works and what sort of methods are useful (vs. just
using Class::Foo on a hash to generate accessors by key).

Steven Lembark                                       85-09 90th Street
Workhorse Computing                                Woodhaven, NY 11421                                     1 888 359 3508

View raw message