|
|
| There's more than one way to do things | |
| PerlMonks |
Re: Re: Re: Re: Re: Short routines matter more in OO?by tilly (Archbishop) |
| on Oct 14, 2003 at 13:21 UTC ( #299098=note: print w/ replies, xml ) | Need Help?? |
|
Why are you assigning to $self->{"property$n"} and then returning $self->{property}? Your @_ test also makes little sense to me. If you are trying to write get/set routines, you would want to get on a single routine, set on 2, and think about throwing an error on 3 or more. Your methods as written require an extra argument to say, "set, pretty please". I was also going to chide you for having methods called property1, property2 without thinking through what you are going to do if you had more than 2 properties, and then I realized that you were likely talking properties of an object, not a computer representation of physical properties. :-) Oh, right. If you are going to have a lot of very similar code, then I think that autogenerating can be good. (Assuming, of course, that the person who will take over the code is capable of figuring out autogenerated code...) For instance: (Yeah, yeah. A million CPAN modules implement variations on the above for you.)
In Section
Meditations
|
|
||||||||||||||||||||||||||