DEV Community

Cover image for Different types of cases in variable naming convention
Hardique Dasore
Hardique Dasore

Posted on

Different types of cases in variable naming convention

There are several different conventions for naming variables in code, and the choice of which one to use often depends on the programming language and the style guide being followed. Here are some common variable naming conventions:

  1. Pascal case: Words in the variable name are concatenated, with the first letter of every word being capitalized. For example, MyVariableName.
  2. Snake case: Words in the variable name are concatenated and separated by underscores. For example, my_variable_name.
  3. Camel case or Dromedary case: Words in the variable name are concatenated, with the first letter of each word except the first being capitalized. For example, myVariableName.
  4. Kebab case: Words in the variable name are concatenated and separated by hyphens. For example, my-variable-name.
  5. Screaming snake case: Similar to snake case, but all letters are capitalized. For example, MY_VARIABLE_NAME.
  6. Train case or Screaming kebab case: Similar to kebab case, but all letters are capitalized. For example, MY-VARIABLE-NAME.
  7. Flat case: Words in the variable name are concatenated, with no capitalization or punctuation. For example, myvariablename.
  8. Upper case: All letters in the variable name are capitalized. This is sometimes used for constants that should not be modified. For example, MYVARIABLENAME.

It's important to follow a consistent naming convention in your code to make it easier to read and understand. Some programming languages have specific conventions that are followed by most developers, so it's a good idea to familiarize yourself with these conventions if you're working with a new language.

Happy Coding!

Top comments (0)