C++, naming member functions

Started by
21 comments, last by cilcoder 18 years, 9 months ago
Some question about naming:

class A
{
public:
    void Name(){}
}

class B
{
public:
    void name(){}
}


What do you think is better Name or name? Problem is afaik in the book Designpatterns they use UpperCase notion, but in the stl they use lowercase. What should i do? Is Stl naming the final truth?
Advertisement
Quote:Original post by Jonus
Problem is afaik Designpatterns use UpperCase notion and stl uses lowercase. What should i do?


Pick one or the other for yourself and use it consistently. Anything beyond that is a question of personal preference.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Quote:Original post by Fruny
Quote:Original post by Jonus
Problem is afaik Designpatterns use UpperCase notion and stl uses lowercase. What should i do?


Pick one or the other for yourself and use it consistently. Anything beyond that is a question of personal preference.
What do you prefer?
Quote:Original post by Jonus
Quote:Original post by Fruny
Quote:Original post by Jonus
Problem is afaik Designpatterns use UpperCase notion and stl uses lowercase. What should i do?


Pick one or the other for yourself and use it consistently. Anything beyond that is a question of personal preference.
What do you prefer?
That you "pick one or the other for yourself and use it consistently." [wink] I personally prefer uppercase, if my opinion amounts to anything.
"We should have a great fewer disputes in the world if words were taken for what they are, the signs of our ideas only, and not for things themselves." - John Locke
Quote:Original post by Jonus
What do you prefer?


I generally use lower_case_with_underscores for members and reserve UpperCaseWords for class names.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
I prefer to put a capital C in front of all my class names, and for function names I will have the first word in the function name be lower case and the rest of the words upper case. And for varibles I use an underscore between words and keep them all lower case.

class CEntity{    public:       CEntity();       void thisIsAnExampleFunction();    private:       int example_varible;};
Im with the camelCaseCrowd just for the record. But I tend to use UpperCase for free functions for stuff akin to generic/functional programming I go with the stl convention of using lowercase.

Maybe Im weird?
HardDrop - hard link shell extension."Tread softly because you tread on my dreams" - Yeats
i use all upper case for class types, and all lower case for everything else:

class TEST{
void so_fuction;
};

TEST test;
Charles Reed, CEO of CJWR Software LLC
Quote:Original post by CJWR
i use all upper case for class types, and all lower case for everything else:

class TEST{
void so_fuction;
};

TEST test;
Most ppl use all upper case for #defines.

I use

UpperCamelCase for classes,
lower_case for structs, member and local variables and generic code,
and lowerCamelCase for private/protected functions,
and ALL_UPPER_CASE for non-local consts and #defines.

This topic is closed to new replies.

Advertisement