Jump to content
  • Advertisement
Sign in to follow this  
krum

C++: UpperCamelCase or lowerCamelCase?

This topic is 4053 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

Which do you prefer for method names? I'm getting ready to start writing a bunch of new code, and I can't decide which to use! So, I'm looking for a compelling reason to use one or the other. :) Thanks!

Share this post


Link to post
Share on other sites
Advertisement
I personally prefer upper camel case, but I don't really mind that much either way.

I'm usually fine with most standard naming conversions, with the possible exception of the one where classes are named in upper camel case with a leading C, such as CSomeClass. That C makes it extremely hard for me to parse the class name at a glance; if you want to use prefixes I prefer separating them out with an underscore like C_SomeClass instead.

Share this post


Link to post
Share on other sites
I use lol_underscores_lol case. But UpperCamelCase is next in terms of preference. I wouldn't wart it up, though. But class names are formal names, no? In English, this means Capitalization.

Share this post


Link to post
Share on other sites
I always follow the conventions of the standard library of which ever language I'm working in, leads to more consistent feeling code that way.

In C++ that means I use underscores but out of those two choices I prefer UpperCamelCase.

Share this post


Link to post
Share on other sites
I like all_lower_with_underscores too, it's much easier to read.

As for UpperCamelCase vs. lowerCamelcase, I use both. At work we use UpperCamelCase for classes, structs, functions, and member variables (after the initial m_ and optional p (for pointers)).
lowerCamelCase is only used for auto variables.

It's a stupid system, but it's better than it was (same plus more warts).

Share this post


Link to post
Share on other sites
What I use:



template < typename BaseClass >
class some_basic_type
{
void foo( BaseClass variable )
{
m_variable = variable;
}
private:
BaseClass m_variable;
};

typedef some_basic_type<int> IntType;

class ConcreteType
{
void foo_bar( );
}



Concrete types use camel case. Templated types use the STL style, since they get typedefed into CC.

This makes for conventient distinction, and makes use of template parameters look natural in the code.

Share this post


Link to post
Share on other sites
I am currently do it the ruby way (ClassName, method_name, variable_name)... I previously used .NET naming conventions.

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!