Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

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

by GrandFather (Sage)
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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2018-06-25 10:40 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.