--- Giacomo Cerrai <[EMAIL PROTECTED]> wrote: > With accessor methods this would be considerably more verbose: > > foo({param => $val, > fields => { $SomeClass->FIELDNAME1 => $val1, > $SomeClass->FIELDNAME2 => $val2, > ... > $SomeClass->FIELDNAMEn => $valn, > }, > }); > ... > foreach my $field ($SomeClass->FIELD4, $SomeClass->FIELD2, ..., > $SomeClass->FIELD10) { > ... > > This becomes quickly unreadable and is not lazy. > Furthermore every fieldname access is a method call which is too much > overhead, especially when you have many fields to deal with.
A couple of problems here. Yes, methods can sometimes be more verbose than variables, but Java made a huge mistake by violating encapsulation. However, at least in Java you get a little bit of type safety (not much, but some). It's important to optimize for correctness first. Readability *must* come after correctness because if a program is incorrect, whether or not it's legible is small consolation. Also, if you're doing a huge amount of work with basic getter/setters, perhaps revisiting your object heirarchy is worthwhile. The more I've learned about OO, the more I've learned that it's about behaviors, not about data. Looking at data instead of behaviors can really hamper effectiveness in OO systems because you become tied to the data when what you really want is modeling of your problem domain's rules. Cheers, Ovid -- Buy the book - http://www.oreilly.com/catalog/perlhks/ Perl and CGI - http://users.easystreet.com/ovid/cgi_course/ Personal blog - http://publius-ovidius.livejournal.com/ Tech blog - http://use.perl.org/~Ovid/journal/