P is for Practical | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I don't like overloaded functions that allow you to both get and set a property. For example:
If that's an object that represents a row in the database, there's a good chance that you can't set the id to a new value. However, the interface doesn't make that clear. If you have multiple "read only" methods, overloading the methods names leads to overloading the brain. Bad Stuff. Another reason for not overloading the methods lies in bugs: if you overload the methods, you have to explicitly write code -- potentially buggy -- to prevent someone from changing read-only values. If you keep accessors and mutators separate, you simply omit mutators for read only attributes. After a much experimentation, I find that I prefer the following:
Aside from the fact that it's less typing, I use Template Toolkit quite heavily and it's easier for our designers to see what's going on.
To me, that just seems much cleaner. Cheers, New address of my CGI Course. In reply to Re: Getter and Setter Function Names
by Ovid
|
|