DEV Community

Cover image for Most Common Programming Case Types
Ekaterine Mitagvaria
Ekaterine Mitagvaria

Posted on • Updated on

Most Common Programming Case Types

Today we are going to learn the most common programming case types.

When you dive into programming you will notice how casing and naming things is not exactly the same as it is in the proper English language. Naming a variable UserIput or userinput makes a big difference. You may be learning a language where it does not matter however sticking to the rules will help you in your future learning of other languages.

The most important lesson to remember is this: never name the same variable with different case types and be consistent with it.
_Do_not Change it hereAnd there because You MAY EndUp with Bugs! _

camelCase

When it comes to camelCase, you always need to start with lowercase word and every next word needs to be uppercase.

Example:

camelCase

PascalCase

Unlike camelCase, every word starts with uppercase letter, even the first one.

Example:

PascalCase

snake_case

In this case, every word needs to be in lowercase letter however we separate then using underscore ("_").

Example:

snake_case

UPPER_CASE_SNAKE_CASE

UPPER_CASE_SNAKE_CASE is almost same like regular snake_case however instead of lowercase letters, all letter need to be uppercase this time.

Example:

UPPER_CASE_SNAKE_CASE

kebab-case

kebab-case visually is really almost like dƶner kebab. Every word is in lowercase letter separated by the hyphen, dash, subtract, negative or minus sign.

Example:

kebab-case

Which one to use?

First, it depends on the language you use and how sensitive it is to the case type.
Secondly, depends on your preference.
Lastly, depends on how the variables have been declared from the very beginning.

Personally, I use JavaScript and I love using camelCase. In React I also use PascalCase. For me, it mostly happened accidentally. I just saw how everyone was doing it and I did the same without really learning the reason I use this or that.
If you are a beginner like me and most likely you know one or two languages, I just suggest sticking to the case which is common in the language you use.

Here are several common examples that have become a general rule, and convention:

JavaScript

  1. camelCase for naming variables
  2. PascalCase for classes

React

  1. PascalCase for naming files and components

Python

  1. snake_case for method names
  2. UPPER_CASE_SNAKE_CASE for constants

Ruby

  1. PascalCase for classes and modules
  2. UPPER_CASE_SNAKE_CASE for constants
  3. snake_case for variables and methods

So, which case type do you love to use? šŸ‘€

Top comments (0)