Anonymous asked in Computers & InternetProgramming & Design · 2 months ago

naming variables in programming, camelCase or under_score , which convention do you prefer/use the most ?

personally I'm not fussed, I interchange between them as I feel and wish.

generally speaking, If the variable name is too long underscore could be useful for readability. Observe:



which one stands out best do you think ?

so which do you prefer fellow coders ? camelCase or under_score ? 

do you use a hybrid_Of the two by any chance ?

1 Answer

  • 2 months ago
    Favourite answer

    It depends on the language and the team I'm on.  I use Java standards in Java, C# standards in C#, and so on, unless the project has a particular set of conventions.

    Consistency across a project is more important than small differences in personal preference. Also more important are "community standards", usually inspired by the standard library of the programming language.  Sometimes the IDE matters, too.  In C# or (if it can't be avoided) VB, Visual Studio has an idea of what your code should look like, and I don't think it's worth it to try to fight that.

    If I write code on my own, it's most likely to be either Python, C or C++.  In all of those, I'll use lower_case_with_underscores for function, method and local variable names.  I'll use TitleCaseNames for class names in Python, but rarely use camelCaseNames  anywhere outside of Java.

Still have questions? Get answers by asking now.