I dislike "getters" but like "setters".
A method called salary() indicates a "thing", a noun. Well, what is this "thing", you may ask. The logical (in my humble opinion) answer is that the salary() method tells you what the "salary thing" is. Implementation: salary() returns the salary. No need for a "get_salary()".
It all becomes different when we want to apply a verb to your "thing". This is when I start working with the method name. Like increase_salary(), set_salary() or (sob) decrease_salary().
As a result, I end up with one method that represents the thing and zero or more methods that affects the thing.
In reply to Re: Getter and Setter Function Names
by Biker
in thread Getter and Setter Function Names
by Wally Hartshorn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |