Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Well, so what? You _do_ know the working of Perl, don't you?

Actually I didn't know about use module (); never having had a need to use it I never bothered to learn it. Usually I've either wanted new subs directly in my name space or I use an instance w/instance methods. I've never used a module which had an interface that should have done the former, but did the latter instead. Just lucky I guess. :)

I'll yield that name clashes probably aren't that big of a deal. And for what is essentially a one-function module, I'd probably opt for explicitly exporting that function (too bad Lingua::EN::Numbers' internals are so messy that this isn't really possible without an interface or a serious rewrite), especially given that there is a way to prevent it (and thanks for pointing that out).

A module author using Exporter gives the programmer a choice - a module author using OO to avoid name clashes doesn't. I know who acts Perlish, and it ain't the latter programmer.

A module author using Exporter is using OO-- subclassing, I believe-- and to good effect. Whether they provide a constructor and instance methods or just class methods is a different story. In the example module it might have been avoided-- but what if you want to have a number-to-English machine that does British working alongside one that does American? You'll need to have two instances of the machine, which I think was the motivation here (no matter how bizarre the result was). This would not have precluded making get_string both an instance and a class method and having the class method rely on a default/class variable for locale.


In reply to Re: Re: Use modules or roll your own? by ichimunki
in thread Use modules or roll your own? by kvale

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-16 04:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found