Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: OOP: How to construct multiple instances of a class at once

by sundialsvc4 (Monsignor)
on Nov 14, 2012 at 22:35 UTC ( #1003898=note: print w/ replies, xml ) Need Help??


in reply to OOP: How to construct multiple instances of a class at once

Moose, of course, has a “getter/setter subroutine” notion, which is very sugar-y.   But you can easily enough do this on your own.   I often define an internal-use-only subroutine, named something like _getBlah (the “_” being my nomenclature for “for internal use only”) which determines if this-or-that information needs to be fetched and if necessary fetches it ... then (in any case) returns $self.   This allows it to be used as a “pass-thru method” in the getter/setter methods, e.g. return $self->_getUserInfo->{'user_name'};.   (Where “$self” is my habitual name for the local variable that refers to “me.”)


Comment on Re: OOP: How to construct multiple instances of a class at once

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (10)
As of 2014-09-19 15:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (142 votes), past polls