Re: OOP or functional?

[prev] [thread] [next] [Date index for 2005/04/02]

From: Steven Lembark
Subject: Re: OOP or functional?
Date: 18:55 on 02 Apr 2005

-- Octavian Rasnita <orasnita@xxx.xx>

> 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
lembark@xxxxxxx.xxx                                     1 888 359 3508

OOP or functional?
Octavian Rasnita 13:29 on 02 Apr 2005

Re: OOP or functional?
Slava Bizyayev 14:01 on 02 Apr 2005

Re: OOP or functional?
jonathan vanasco 17:10 on 02 Apr 2005

Re: OOP or functional?
Steven Lembark 18:55 on 02 Apr 2005

Generated at 14:43 on 11 Apr 2005 by mariachi v0.52