Naming convention guide

Camel Case Guide for Clean Code

camelCase is a naming style in which the first word starts with a lowercase letter and each later word starts with a capital letter, with no spaces or separators. For example, “user profile image” becomes “userProfileImage”.

The rules of camelCase

Start with a lowercase word, capitalise the first letter of every following word and remove spaces, hyphens and underscores. Preserve enough of the original meaning that another developer can understand the identifier without opening more files.

  1. Break the source phrase into individual words.
  2. Lowercase the first word.
  3. Capitalise the first letter of each remaining word.
  4. Join the words and remove separators.

Good camelCase examples

Clear identifiers describe the value or action rather than how the code happens to implement it.

UseInputResult
Variablecurrent user namecurrentUserName
Booleanis account activeisAccountActive
Functioncalculate order totalcalculateOrderTotal
Event handlerhandle form submithandleFormSubmit
API propertycreated at timestampcreatedAtTimestamp

camelCase versus PascalCase and snake_case

camelCase begins with a lowercase letter, PascalCase begins with a capital letter and snake_case separates lowercase words with underscores. JavaScript variables and functions commonly use camelCase, React components commonly use PascalCase, and Python code commonly uses snake_case.

Acronyms and numbers

Acronym handling varies by project. userId is often easier to read than userID, but an established codebase may use a different convention. Numbers can remain inside an identifier when they add meaning, such as addressLine2. Consistency with the surrounding code is more important than inventing a one-off rule.