Sitemap
Vikash Kumar

Vikash Kumar

Press enter or click to view image in full size

Casing in Coding

2 min readAug 1, 2023

Is code for Humans or Machines?

Do we need to focus on casing while writing code because computers can understand anything?

Yes, we need to focus on the casing.

Casing is very necessary while writing code because humans also need to understand what we have written.

So code should be understandable by humans and machines.

Now the question arises of what we should follow when it comes to writing code.

Basically, there are 4 general practices coders use to write code

  • camelCase
  • snake_case
  • kebab-case
  • PascalCase

camelCase:

camelCase is the way of writing variable names, function names, and class names in programming languages like Java, JavaScript, Python, and others by joining the word and capitalizing every word after the first word just like how we see the hump on the camel back.

Get Vikash Kumar’s stories in your inbox

Join Medium for free to get updates from this writer.

Suppose we have 2 words “my” and “value”, we will write them as:

myVal=5
print(myVal)

snake_case:

Have you ever seen a snake around a branch of a tree, the way it wraps around the branch, snake case gives the same feeling to the word written in this format.

It is used to write the name of variables, functions, and other identifiers.

Suppose we have 2 words “hello” and “world”, we can write these in snake_case by joining both of them using the underscore “_”.

def my_func:
print("camel_casing")

kebab-case:

Kebab, the word itself define the feeling of how the food pieces are stuck in a rod and the aroma of that.

Similarly in kebab-case, the word is joined using a dash(“-”), which looks like the words are joined using some rod. Suppose we have 3 words “hello”, “beautiful” and “world”. It could be written as

hello-beautiful-world

They are generally used in writing variable names, filenames, or URLs.

PascalCase:

It is the same as camelCase, the only difference is that we capitalized the initial word also while joining the word along with other words as we do in camelCase. These are generally used in writing the names of classes, methods, variables, and other identifiers.

If we take the previous example it can be written as

HelloBeautifulWorld

in PascalCase.

So, these are the casing convention that are widely used while writing code to increase human readability and write clean code.

--

--