Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Accessor methods again.

by gargle (Chaplain)
on Oct 04, 2005 at 14:51 UTC ( [id://497270]=note: print w/replies, xml ) Need Help??


in reply to Accessor methods again.

Hi,

As always, it depends. If you use different accessor methodes for each attribute you can easility mimic public,private, and protected access. See Re: OO - best way to have protected methods for more. If you don't need, don't use (kiss ;))

Different setter methods have an advantage: you can put code in it to check the parameters. As the setting for the attribute in question only occurs in one place your code becomes simpler to update.

A single getter/setter shared by all attributes can do the same but becomes complex the moment you have many attributes, plus, you loose the public, private, protected simplicity.

--
if ( 1 ) { $postman->ring() for (1..2); }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-04-19 02:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found