Jump to content
  • Advertisement
Sign in to follow this  
Jonus

C++, naming member functions

This topic is 4798 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Quote:
Original post by Jonus
What do you prefer?


I generally use lower_case_with_underscores for members and reserve UpperCaseWords for class names.

Share this post


Link to post
Share on other sites
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;
};

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
i use all upper case for class types, and all lower case for everything else:

class TEST{
void so_fuction;
};

TEST test;

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!