Re: thisIsAMemberFu nctionName vs this_is_a_membe r_function_name
Slash wrote:
[color=blue]
> Is there any "standard" naming convention for member functions?[/color]
No. This is purely a matter of style.
[color=blue]
> Which one should I prefer?
>
> thisIsAMemberFu nctionName
> vs
> this_is_a_membe r_function_name[/color]
this->functionName
[color=blue]
> Although most books and eminent authors (like Herb Sutter) recommend
> the first approach, I certainly feel the second leads to more readable
> names. In fact the STL itself uses the second naming convention.
>
> Why then is the first convention usually recommended?
>
> I understand that all this is strictly a matter of personal taste but,
> since most of you guys here are pros, what do you all prefer?[/color]
The best advice that I can give you is
Keep a Thesaurus handy.
Choose short complete [English] words for function names,
constants, variables and types. Don't *mangle* them.
Try to avoid words like data, object, routine that have special meaning
or that are redundant in the context of a C++ program.
If you are writing scientific or engineering applications
you can implement long formulas with a single compact expression
using single character symbols annotated with comments:
// definition // nomenclature
// ---------------------------------------------------
double a = 9.8; // acceleration (meters/second/second)
double m = 1.0 // mass (kilograms)
double F = m*a; // force (Newtons)
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.m oderated. First time posters: Do this! ]
Slash wrote:
[color=blue]
> Is there any "standard" naming convention for member functions?[/color]
No. This is purely a matter of style.
[color=blue]
> Which one should I prefer?
>
> thisIsAMemberFu nctionName
> vs
> this_is_a_membe r_function_name[/color]
this->functionName
[color=blue]
> Although most books and eminent authors (like Herb Sutter) recommend
> the first approach, I certainly feel the second leads to more readable
> names. In fact the STL itself uses the second naming convention.
>
> Why then is the first convention usually recommended?
>
> I understand that all this is strictly a matter of personal taste but,
> since most of you guys here are pros, what do you all prefer?[/color]
The best advice that I can give you is
Keep a Thesaurus handy.
Choose short complete [English] words for function names,
constants, variables and types. Don't *mangle* them.
Try to avoid words like data, object, routine that have special meaning
or that are redundant in the context of a C++ program.
If you are writing scientific or engineering applications
you can implement long formulas with a single compact expression
using single character symbols annotated with comments:
// definition // nomenclature
// ---------------------------------------------------
double a = 9.8; // acceleration (meters/second/second)
double m = 1.0 // mass (kilograms)
double F = m*a; // force (Newtons)
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.m oderated. First time posters: Do this! ]
Comment