Variable Naming Conventions

Cosmic

Manners maketh man
Joined
Jul 4, 2009
Messages
12,888
Reaction score
951
FP$
29
Do you follow any interesting conventions when naming variables? For example, I know a lot of C programmers are in to weird stuff like m_iNum, which many companies actually mandate. I, personally, will use camelCase. Nothing much special other than that.
 
Depends on the language. I'm almost always using camelCase or PascalCase when I can, but I will use snake_case when I'm working in a context where its in the convention.

Depending on the context, in C and even C++, I will use Hungarian notation (e.g. szTitle, bSuccess).
 
I personally prefer snake_case mostly because it makes it makes it incredible clear that there are separate words in the variable, while with camelCase it can be slightly hard to differentiate between the two word, because it kind of flows and is perceived as one word.
 
I use camelCase as well.. What I hate more though (a personaly preference) is the bracket structures =0

if($boo) {

}


I prefer
if($boo)
{

}
 
I love the bracket structures (which you hate)!
This is because they look kinda clean and it's one less line of code and if you are working on a big project, you literally save hundreds of lines of code just by keeping the opening bracket on the same line.

When the opening bracket is on the next line, it kind of feels like a different element, not a part of the name itself.
 
Looking through a project I've started working on, I tend to use things such as $RootAddress or $FirstName. However, in HTML, my divs are set out as such: "content_right_main_notices_title"
 
In C# or other OOP languages, I tend to use camelCase for private variables and PascalCase for public variables and properties. In C, I tend to use snake_case for functions and pascalCase for variables.
 
Back
Top Bottom