Naming Conventions

A rule or standard for how variables are named in a programing language.

What are popular naming conventions in programming?

Each programming language has their own set of rules and standards for variable naming conventions.

Here are some of the common conventions that you will see. Being consistent in your naming style throughout your code is critical.

  • camelCase - first letter lower case - each new word upper case. This is the most common style in modern programming languages
  • PascalCase - the first letter of each word upper case - common for class names in many modern languages but also often used for function/method names
  • lowercase - all letter lower case - no spaces
  • snake_case - all letters lower case - underscore for spaces - common for databases like PostgreSQL because table and column names do not support upper case letters
  • ALL_CAPS - all letters UPPER CASE - under score for spaces - common for constant declarations in some programming languages
  • kebab-case - all letters lower case - underscore for spaces - common in CSS for id and class naming standards
  • _underscorePrefix - private variables are often prefixed with an underscore - it is less common in modern languages, but still in use
  • strHungarianNotation - prefix the variable with the type stored in the variable (old school) - this is uncomon in modern languages partly because in modern languages there are too many types to be able to prefix everything.

Level: Novice · More General terms at this level

Updated