Perl Monk, Perl Meditation | |
PerlMonks |
Re: OO Getters/Settersby dragonchild (Archbishop) |
on Dec 31, 2003 at 14:58 UTC ( [id://317894]=note: print w/replies, xml ) | Need Help?? |
Personally, if I have to uses accessors/mutators, I use the following:
Now, I have used generic set/get routines. We had a set() and a get(), that took attribute names. So, you would have:
Except, there are a few issues. How do you handle misnamed attributes? What about attributes whose values are arrayrefs? It gets messy. And, it's even worse if you have a single method for doing all accessor/mutator functionality. Personally, I'd recommend against this. Maintainability will suffer. ------
Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.
In Section
Seekers of Perl Wisdom
|
|