Jump to content
  • Advertisement
Sign in to follow this  
Waaayoff

Poll: Do you capitalize the start of your variables/functions?

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

Advertisement
If you want to submit a poll idea you can. In any case, my capitalization conventions depend on what language I'm using. Ex: in C#, I use the .NET naming conventions which, for instance, specify names LikeThis for public functions, but in C++ I use names like_this for functions and variables.

Share this post


Link to post
Share on other sites
No. In C++ I find the following convention the most readable with the least amount of conflicts.

Class names in upper CamelCase.
Variables/object instances in lower camelCase.
Methods/functions in load camelCase.
Namespaces in all lowercase.
Don't attach any warts to variable names (no mCamelCase or m_camelCase for members).

I find C#'s convention (upper CamelCase for methods/properties) to be more unreadable when it starts to get busy. It is nice that all C# libraries follow the same convention though.

I do wish C++ had a standard naming convention (or that the standard library used a more modern one).

Share this post


Link to post
Share on other sites
in C#


namespace fooman
{
class Foo
{
//Varaibles
private int iMyAge;
private string sMyName;
}
}



for private variables I always put a 'wart' on the front, it means in larger classes I can find what I need on intellisense by simply knowing why type it is e.g.

I wanna find my age, and I know its going to be an int I just type 'i' and it shows me all the integers I have.

Share this post


Link to post
Share on other sites
Quote:
Original post by Andy474
in C#
*** Source Snippet Removed ***

for private variables I always put a 'wart' on the front, it means in larger classes I can find what I need on intellisense by simply knowing why type it is e.g.


If your class is large enough that you can't keep track of the fields available, you're doing something wrong.

That said, I generally follow language standards like SiCrane. Though I will currently tend to fall back to C# standards in C++ and other languages if I'm working on throw away code.

Share this post


Link to post
Share on other sites
For me, it depends on what I am programming.

Variables

theObject for variables in Objective-C, Java, and C#
the_object for variables in C

Function Name

TheFunction for Objective-C, Java, and C#
the_function for C

I think most important is to avoid conflict with the language's keywords, while being consistent enough to read your own code.

I also like to write

while()
{

}

instead of

while () {

}

because I hate seeing ") {" for some unknown reason.

Share this post


Link to post
Share on other sites
lowercase

EG

string lowerCase() {}

I just feel more comfortable with it than LowerCase(), and I find I can type lowerCase faster than LowerCase.. :p

Share this post


Link to post
Share on other sites
Edit: In C++

I do:

All variables have at least 1 underscore (sometimes trailing like_)

Local variables are lower_case, Class or Global or Namespace variables are Upper_Case

Classes are UpperCase with no underscores

Methods are also UpperCase with no underscores

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!