Reputation: 1289
I see a lot of different styles of variable names used in different kind of languages. Sometimes these names are lowercase and using underscores (i.e. test_var
) and other times I see variables like testVar
.
Is there a specific reason why programmers use different variable name styles in different languages?
Upvotes: 1
Views: 1964
Reputation: 3
I urge you to follow language standards. I work on a team that has had many developers working on the code over the years, and very few standards have been followed. The majority of our code is nearly unreadable. I have been working on a standardization project for the last several months. It has been very difficult to enforce and get buy-in. I'm hopeful that people will come around as they start seeing the benefits of easy to read code.
For naming conventions/standards keep this in mind:
Upvotes: 0
Reputation: 63815
There is no real reason. Each language and sometimes even platform can have varying naming conventions.
For instance, in .Net TestVar
would be seen if it was a public class variable. In C++, testVar
would probably be opted for. In Ruby, test_var
, etc. It's just a matter of preference by the community and/or creators.
Upvotes: 0
Reputation: 7941
As Wiki says :
Reasons for using a naming convention (as opposed to allowing programmers to choose any character sequence) include the following:
to reduce the effort needed to read and understand source code;1
to enhance source code appearance (for example, by disallowing overly long names or abbreviations).
Also there are code conventions in companies that care about readability of their code. This simplify the code sharing between programmers and they don't spend time to understand what means variables name "aaa" and "bbb".
Upvotes: 0
Reputation: 378
It's really just the convention for that programming language.
For example, most Java programs use camel-casing (testVar) while a lot of C programs use _ to seperate words (test_var).
It's completely the choice of the programmer, but most languages have "standard" naming conventions.
Upvotes: 2