If I have user id variable, what is correct java naming convention for it?
userId or userID
For variables, the Java naming convention is to always start with a lowercase letter and then capitalize the first letter of every subsequent word. Variables in Java are not allowed to contain white space, so variables made from compound words are to be written with a lower camel case syntax.
Class names should be nouns, in mixed case with the first letter of each internal word capitalized. Try to keep your class names simple and descriptive. Use whole words-avoid acronyms and abbreviations (unless the abbreviation is much more widely used than the long form, such as URL or HTML).
If you are a programmer and you are referring to the row number of a record in a table, then you are referring to a Unique identity or Unique identifier, both of which can be referred to an Id. Because the letters are only representing a single word the "d" should never be capitalized.
There are some rules you have to follow for naming identifiers: The first character of the identifier must be a letter of the alphabet (upper or lowercase) or an underscore ('_'). The rest of the identifier name can consist of letters (upper or lowercase), underscores ('_') or digits (0-9).
I think I read somewhere that the best guideline is to always capitalize only the first letter of an acronym (i.e., if you have a user TTL where TTL is some random acronym in your project, then it's best to write userTtl).
This makes sense, since it solves some problems. For example, say you want a user id counter. Readability of userIDCounter is worse than userIdCounter. For a longer acronym, it gets even worse.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With