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

Re: RFC US Region Module

by Aristotle (Chancellor)
on Jul 06, 2003 at 13:06 UTC ( [id://271776]=note: print w/replies, xml ) Need Help??


in reply to RFC US Region Module

I don't see why you made this module object oriented - you're not making any use of $self. Also, you're reading DATA in your new() method - why? The second and subsequent instantiation of an "object" in your class will not have anything to initialize. Pull that while loop out of the method and get rid of new (as well as $self in the other functions). Of course the function names are somewhat unfortunately named for those who'd want to import them; maybe prefix them with us_ or some such.

As far as the name is concerned I'd definitely go with Geography::US::Census::Regions. Locale is the wrong namespace for this module. A module's "innermost" name portion should express what that module deals with; here, that is regions. It deals with those according to the census, hence Census::Regions. Regions::Census would mean it deals with the census according to the regions, which makes no sense.

Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Re: RFC US Region Module
by trs80 (Priest) on Jul 06, 2003 at 19:19 UTC
    If I leave it OO don't I avoid the issue of the function name collision you mention? While I agree there is no current or compelling reason for this module to be OO it does seem to work easily enough to provide the functionality I need. Would I see benefits from it being non-OO?

    The DATA read has been moved outside of the new since that was the wrong spot for it and subsequent object creations would have resulted in an empty hash ref being assigned to $self.

    Of the names I felt the Geography namespace would be best, but I am still struggling with the Census::Regions / Regions::Census issue for these reasons:
    1. Geography::US::Regions would leave the name space open for additional Region separation specific modules each named for their source, as in this case Census
    2. Geography::US::Census seems limiting to me because the number of Geography based concepts that would deal with Census seem limited.

    Thanks for the feedback.
      If I leave it OO don't I avoid the issue of the function name collision you mention?

      Perl uses packages to implement OO but packages don't necessarily imply OO. Packages provide namespaces that help avoid function and variable name collisions. Those functions don't necessarily have to be written in an OO fashion, though.

      90% of every Perl application is already written.
      dragonchild
      The collisions are already avoided by writing something like Geography::US::Census::Regions::state, which is admittedly clumsy. You can use alternative exporters such as Exporter::Tidy to provide your users the option to choose a prefix or alias of their preference for the exported functions. OO is the wrong tool here.

      Makeshifts last the longest.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-03-28 11:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found