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

Started by
24 comments, last by Brain 13 years, 6 months ago
Incidentally, i really think this forum needs to support polls.
"Spending your life waiting for the messiah to come save the world is like waiting around for the straight piece to come in Tetris...even if it comes, by that time you've accumulated a mountain of shit so high that you're fucked no matter what you do. "
Advertisement
Yes.
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.
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).
Quote:Original post by SiCrane
If you want to submit a poll idea you can.

I didn't know that, thanks :)
"Spending your life waiting for the messiah to come save the world is like waiting around for the straight piece to come in Tetris...even if it comes, by that time you've accumulated a mountain of shit so high that you're fucked no matter what you do. "
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.
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.
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.
lowercase

EG

string lowerCase() {}

I just feel more comfortable with it than LowerCase(), and I find I can type lowerCase faster than LowerCase.. :p
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

This topic is closed to new replies.

Advertisement