Get job ready skill with Career Paths     |       Start learning for free!

close
Cart icon
User menu icon
User icon
Lightbulb icon
How it works?
FAQ icon
FAQ
Contact icon
Contact
Terms of service icon
Terms of service
Privacy policy icon
Privacy Policy
Zdjęcie główne artykułu.

The most common programming notations

A programming notation is a way we write the names of the elements like variables, functions or classes.

You may note that any element in the code can be named in multiple ways. You may use Capital Letters. You may use small letters. You may put spaces between words. You may seperate_words_with_undserscores etc. With so many possibilities one needs to stick to some rules in order to keep the code clean and readable.

There are some very common programming notations that define the way we write the names. Let’s take a look at them.

camelCase

If you look carefully at the camelCase you may find that it really looks like…camel. Or you may not. Really, it doesn’t matter. What you should keep in mind is the fact that the first word always starts with a small letter. And all following words start with Capital Letter. Note also that there are no spaces between words. Some examples:

accountList
firstNumber
itemsCounter
configureTestingModule

This notation is very common and you can find countless examples if you look around. Just take a look at some random code and there is a great chance that you will find names written in camelCase

PascalCase

PascalCase differs from camelCase with a single detail - all words start with capital letters. Examples:

AppComponent
ShoppingCartComponent
AppRoutingModule

We could say that PascalCase is almost as common as camelCase. There are plenty of examples to be found.

snake_case

What do you see if you look at snake_case? See the snake or not? Note that this notation uses all small caps and there are underscores between words. Examples:

my_var
get_random_number
create_account_list

This notation is very common in the Python language. There are some additional variants. Take a look:

EVN_NAME
TAX_VALUE

That ALL_CAPS variant is often utilized to name constants in languages like PHP, Java and others.

kebab-case

This notation could also be described as a variant of snake case. The only difference is that kebeb-case uses dashes instead of underscores. Let’s take a look at some examples:

text-decoration
get-user-info
article-list

This notation is common in URLs. It is also used to name CSS properties.

Hungarian notation

This notation has more of a historical meaning than a real one. Today, it simply fell out of favor. It has one interesting feature: we prefix the name of the variable with the information about its intended purpose or data type. It should be clear if you take a look at this example:

strUserName

Note the word str at the beginning of the variable name. It suggests that this variable should store the data of string type. Here is another example:

iAge

This one has an i at the beginning. It suggests that this variable should store integer numbers. We said that Hungarian Notation has fallen out of favor. You may still come across it in some legacy code.

Which notation is better for your projects?

This is a really, really wrong question. No notation is better than others. They are equally good as long as you stick to the one that works best for your needs.

If you are writing code for yourself, just choose the notation you like the best. And if you are working as a part of a larger team then you will be provided with some coding guidelines. Such guidelines will provide you with the preferred way of naming elements. And you will have to stick to them - that’s all.