in reply to RE: Power of single objects
in thread Power of single objects

Personally, I feel that some modules nowadays are trying to use objects because it's "cool", even though the module would be better off being used in a functional manner.

My dear Fastolfe, thou are a bit slow: modules serve to encapsulate variables, even for a collection of related functions. 'tis not only for OOP that thou wilt find modules of great use in parting the red seas of programming jobs that lies ahead for ye.

Replies are listed 'Best First'.
RE: RE: RE: Power of single objects
by Fastolfe (Vicar) on Oct 19, 2000 at 22:16 UTC
    Hmm.. Maybe one of us is misunderstanding the other.. I have no problem with modules, I just have a problem with the overuse of OOP in cases where it just adds complexity without any benefit. Consider some module "Object", which has the sole task of performing some_operation on $item, the behavior of which could change, depending on the value of some_variable.
    use Object; my $obj = new Object; $obj->some_operation($item); $obj->some_variable($argument); $obj->some_operation($item); # versus use Object; some_operation($item); some_operation($item, $argument);
    In my opinion, there are many types of modules that, for whatever reason, unnecessarily go with an OO approach, even though the paradigm doesn't quite fit, and we get little benefit out if it. I really don't know how to describe the best way to decide. For me, I just look at my package in both ways. If it "feels" right in an object point of view, if I can see a benefit to creating multiple "instances" of my module in the form of objects and toss those around, I'll build it in OO style. If my resulting implementation is going to be a lot more efficient and simpler in a functional style, I'll go that route. Perhaps it's just personal preference...