Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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

by sundialsvc4 (Abbot)
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 making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2015-07-05 05:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls