Syntactic Confectionery Delight | |
PerlMonks |
Re: Object Constructors - Advice of experienced OO Perl Monksby jeffa (Bishop) |
on Oct 06, 2005 at 17:53 UTC ( [id://498002]=note: print w/replies, xml ) | Need Help?? |
To answer your initial question -- that depends on what you are trying to solve. :) You need to be more specific to get a answer with more value than that. You need to think in terms of readability, maintainabilty, correctness, robustness, etc. Here is a constructor i like use when the situation is quick and dirty That's all you need -- you can add attributes later. However, if i am writing production code, i might opt for the more verbose version:
I try to use Class::MethodMaker whenever i can, i just like that module. Here is an example where i use that module to turn XML into real objects: XML::Simple + Class::MethodMaker. Hope this helps. :) jeffa L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
In Section
Seekers of Perl Wisdom
|
|