Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Confused about standard identifier naming

reading a book, it says that these two are obligate conventions:

  • do not use underscore in identifiers
  • identifier should not begin with capital letter

But in many places then I can see, especially in properties, that author does not follow that, e.g.:

private int x

and

public int X..

The same with underscores..sometimes he uses _x and X for properties.

What is the correct naming convention, please?

like image 348
Cocodrilo Avatar asked Dec 03 '22 03:12

Cocodrilo


1 Answers

The rules are not the same for all identifiers. And there are multiple standards around, all are good as long as they are used consistently.

What I remember from the MS guidelines:

  • class (type) names and public members use PascalCasing
  • private members, local vars and parameters use camelCasing

But camelCasing just means "don't start with a capital", field, _field, mField and m_field all qualify.

like image 184
Henk Holterman Avatar answered Dec 07 '22 22:12

Henk Holterman