A naming convention is a set of rules for choosing the character sequence to be used for identifiers which denote variables, types, functions, comments etc. Many developers, community, standards have established their own set of conventions.
Why we need naming convention :
- To reduce the effort needed to read and understand source code
- To enable code reviews to focus on more important issues than arguing over syntax and naming standards.
- To enable code quality review tools to focus their reporting mainly on significant issues other than syntax and style preferences.
Followings are some naming conventions typically used by developers :
Pascal case is a subset of Camel Case where the first letter of every word is capitalized. That means, `userAccount` is a camel case and `UserAccount` is a Pascal case. You can use camelCase for variables and PascalCase for Class names or Constructors.
( Way to remember: Pascal is a proper noun so capitalize the first letter. Camel is a common noun, so do not capitalize the first letter. )
Why we need naming convention :
- To reduce the effort needed to read and understand source code
- To enable code reviews to focus on more important issues than arguing over syntax and naming standards.
- To enable code quality review tools to focus their reporting mainly on significant issues other than syntax and style preferences.
Followings are some naming conventions typically used by developers :
- Snake case (or snake_case) : This is the way of writing words in which the elements are separated with one underscore character (_) and no spaces, with each element's initial letter usually lowercased within the compound and the first letter either upper- or lowercase—as in "foo_bar" and "Hello_world".
- Kebab Case (or kebab-case) : It is same as snake case, except hyphens rather than underscores are used to replace spaces—as in "foo-bar" and "Hello-world".
- Pascal Case (or PascalCase) : This means that the first letter of every word in the name is capitalized.
- Camel Case (or camelCase) : It is the same as Pascal Case, but the first letter of the first word is lowercased.
Pascal case is a subset of Camel Case where the first letter of every word is capitalized. That means, `userAccount` is a camel case and `UserAccount` is a Pascal case. You can use camelCase for variables and PascalCase for Class names or Constructors.
( Way to remember: Pascal is a proper noun so capitalize the first letter. Camel is a common noun, so do not capitalize the first letter. )
Post a Comment