Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2014-07-26 12:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (176 votes), past polls