Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Re: Use modules or roll your own?

by demerphq (Chancellor)
on Jul 29, 2002 at 12:21 UTC ( [id://185958]=note: print w/replies, xml ) Need Help??


in reply to Re: Use modules or roll your own?
in thread Use modules or roll your own?

Im kind of curious as to what you would consider "pointlessly using OO". Care to expand on that with some examples?

Cheers,

Yves / DeMerphq
---
Writing a good benchmark isnt as easy as it might look.

Replies are listed 'Best First'.
Re: Use modules or roll your own?
by Abigail-II (Bishop) on Jul 29, 2002 at 12:41 UTC
    use Lingua::EN::Numbers; my $n = new Lingua::EN::Numbers; $n -> parse (1281); print $n -> get_string, " fish in the sea.\n";
    Which is the reason I wrote Lingua::EN::Numbers::Easy where you can do:
    use Lingua::EN::Numbers::Easy; print "$N{1281} fish in the sea.\n";
    to do the same.

    Abigail

      The problem there isn't a "pointless use of OO", but rather an API that isn't very sensible. One is tempted to ask why the module has an interface that forces a user to create an instance, give the instance a number, and then retrieve a string from the instance when a simple class method exported would have worked more easily. I mean, then I have to remember whether the current number in the instance is the one I want-- which is the sort of "internal state of object" knowledge the rest of my program shouldn't have to be thinking about. It would bother me a lot less if the module had fewer steps:
      use Lingua::EN::Numbers; my $n = Lingua::EN::Numbers->new; print $n->get_string(1281), " fish in the sea.\n"; #or use Lingua::EN::Numbers qw(get_string); print get_string(1281), " fish in the sea.\n";
      With this sort of interface I have a choice of whether or not to pollute my namespace with a function name (like with CGI.pm, I prefer not to attempt to export all those HTML markup tags as function names).
        One is tempted to ask why the module has an interface that forces a user to create an instance, give the instance a number, and then retrieve a string from the instance when a simple class method exported would have worked more easily. I mean, then I have to remember whether the current number in the instance is the one I want-- which is the sort of "internal state of object" knowledge the rest of my program shouldn't have to be thinking about.

        This is exactly what I mean by "pointless OO". Even your suggested class method is "pointless OO" to me. It doesn't buy you anything, except additional clutter.

        Abigail

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-24 07:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found