Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: Difference between Function-oriented and object-oriented in Perl

by GrandFather (Cardinal)
on Nov 23, 2007 at 06:25 UTC ( #652506=note: print w/ replies, xml ) Need Help??

in reply to Difference between Function-oriented and object-oriented in Perl

Object oriented interfaces to a module are useful where it is useful (or essential) to retain some state between calls into the module.

Functional interfaces to modules are useful where a simple interface is desired and no state need be retained between calls into the module.

Some modules provide both interface modes. List::Compare and List::Compare::Functional provide OO and Functional access to the same set of facilities. If you want to compare the same set of values in various ways the OO interface has a large advantage because a lot of preliminary work gets done only once. If you want to only compare the values in one way there is a slight advantage in terms of coding in using the functional interface.

With Functional interfaces you generally have to option of polluting your name space with all the functions the module provides, or you have to remember to explicitly import the functions you require. With an OO interface you don't need to import any additional symbols into your name space at all.

Generally if there is an OO interface available you are better to use it just because you avoid problems with importing symbols and potential ambiguities over how a particular symbol may be resolved.

Perl is environmentally friendly - it saves trees

Comment on Re: Difference between Function-oriented and object-oriented in Perl

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://652506]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2014-09-22 10:50 GMT
Find Nodes?
    Voting Booth?

    How do you remember the number of days in each month?

    Results (189 votes), past polls