Wally Hartshorn has asked for the wisdom of the Perl Monks concerning the following question:
I'm posting this under SoPW because there isn't a category called "Pointless Debates". :-) What are people's preferences for how to name "getter" functions? One style guide I've read recommends naming functions after the thing that is returned -- e.g. "salary()". Another style guide recommends naming such a function "get_salary()".
Is there any predominant style in the Perl community? Does the answer depend on whether the function is simply returning the salary or is actually computing it first? Does the answer depend on whether the function is part of a package or is actually a method in an object?
On a related topic, do you prefer to see a separate "set_salary()" function, or do you prefer to see the same function performing both... uh... functions?
Like I said, "Pointless Debates". :-) Still, I'm curious as to whether there is a clear preference.
Wally Hartshorn
(Plug: Visit JavaJunkies, PerlMonks for Java)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Getter and Setter Function Names
by Ovid (Cardinal) on Apr 09, 2003 at 21:36 UTC | |
Re: Getter and Setter Function Names
by BrowserUk (Patriarch) on Apr 09, 2003 at 22:29 UTC | |
Re: Getter and Setter Function Names
by DrManhattan (Chaplain) on Apr 09, 2003 at 22:39 UTC | |
Re: Getter and Setter Function Names
by Mr. Muskrat (Canon) on Apr 09, 2003 at 21:40 UTC | |
Re: Getter and Setter Function Names
by vek (Prior) on Apr 09, 2003 at 23:24 UTC | |
Re: Getter and Setter Function Names - content warning:contains references to Java
by Elgon (Curate) on Apr 10, 2003 at 00:51 UTC | |
Re: Getter and Setter Function Names
by Biker (Priest) on Apr 10, 2003 at 14:14 UTC | |
Re: Getter and Setter Function Names
by zby (Vicar) on Apr 10, 2003 at 15:04 UTC | |
by Biker (Priest) on Apr 10, 2003 at 15:39 UTC | |
by zby (Vicar) on Apr 10, 2003 at 15:44 UTC |