Hi all,
Is it good practice to start class member variables with an underscore? The reason I ask is for ambiguity in a function in a class that is derivative of SPObject.
class SPObject has member "repr". So now if I subclass from that and add a method to my class like "sp_do_something(XML::Node repr)", there is an ambiguity in the method. Perhaps underscoring the class member variables is better...
Ciao, Johan
2010/5/18 <J.B.C.Engelen@...1578...>:
Hi all,
Is it good practice to start class member variables with an underscore? The reason I ask is for ambiguity in a function in a class that is derivative of SPObject.
class SPObject has member "repr". So now if I subclass from that and add a method to my class like "sp_do_something(XML::Node repr)", there is an ambiguity in the method. Perhaps underscoring the class member variables is better...
Ciao, Johan
According to the Inkscape coding style, private variables should begin with underscores, but it's not possible to change this for SPObject without rewriting a lot of code (it's a public field). So you have several options: a) use a different parameter name, e.g. "node" or "xml" b) explicitly refer to the member variable through this, e.g. "this->repr". Saying "repr" alone will refer to the parameter, since parameter names have closer scope than member variables and thus take precedence.
By the way, method names shouldn't have any prefixes (like sp_), and use camelCase ("Java style" naming) instead of underscores. http://inkscape.org/doc/coding_style.php
Regards, Krzysztof
participants (2)
-
unknown@example.com
-
Krzysztof Kosiński