You don’t have to be a professional programmer to know that the computers have their own languages. But, you certainly have to have a good command of programming to be able to communicate with the computer in its language.
One of the things that people struggle the most with while learning computer programming is the naming conventions (the rules for characters’ sequence for various identifiers).
Table of contents
Programming Naming Conventions
To help make it a little easier for you, here’s a quick roundup of the most common naming conventions used in programming:
1. Camel Case
Camel case, sometimes also referred to as Lower Camel Case, is a naming convention that requires capitalizing the first letter of every word in a name or sentence except that of the first word. The most common examples of this case style are eBay, iPhone, and iPad. Here’s how it’s done:
Raw:
The most common types of naming conventions
Camel Case:
theMostCommonTypesOfNamingConventions
In the world of coding, the camel case is most commonly used for naming variables but can also sometimes be used for functions.
2. Pascal Case
Pascal case style is essentially a type of camel naming convention, but it is generally referred to with this name to avoid confusion. However, you may hear some people call it the Upper Camel Case. The rules of this naming convention are the same as that of the camel case, except that here the first of all the words are capitalized, including the first word.
PowerPoint, WordPress, and JavaScript are some familiar names written using this convention. It’s generally used to name classes, interfaces, and enums but is sometimes also used for functions and namespaces.
Here’s how you write something in the pascal case…
Raw:
The top destinations for solo travelers
Pascal Case:
TheTopDestinationsForSoloTravelers
3. Snake Case
Generally used for declaring constants and database field names and naming variables, the snake case style involves using “underscore” to separate words. However, it’s divided into two subtypes depending on the use of capitalization. When written in lowercase, it’s simply called snake case, and when written in all caps, it’s called Capitalized Snake Case or Screaming Snake Case. Let’s take a quick look at how both of these are done in practice:
Raw:
The quick brown fox jumps over the lazy dog
Snake Case (Regular):
the_quick_brown_fox_jumps_over_the_lazy_dog
Screaming Snake Case:
THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG
The regular snake case style is often used for naming database tables, whereas the screaming snake case is conventionally used for constants.
4. Kebab Case
Kebab case naming convention involves using small letters and separating words with the dash. It’s often used for class naming, ids, REST endpoints, and URLs. Here’s how:
Raw:
Skincare tips for summer
Kebab Case:
skincare-tips-for-summer
5. Uppercase
As evident from the name, Uppercase is a naming convention that involves writing in capital letters. It can be done in different ways:
Raw:
The early bird gets the worm
Uppercase Styles:
THEEARLYBIRDGETSTHEWORM
THE_EARLY_BIRD_GETS_THE_WORM
THE-EARLY-BIRD-GETS-THE-WORM
Which is the Best Programming Case Style?
Although various naming conventions are preferred for different purposes, there is no single best method to combine words in coding. So, you can use any. However, it’s best to be consistent with the style throughout a program.
Here are common cases used with popular programming languages
- Javascript/Java/C#: camelCase
- Python/PHP: snake_case
- CSS: kebab-case
Conclusion
The most effective way to combine words varies depending on the situation. However, it is recommended to maintain consistency in the style of capitalization. It is beneficial to establish a shared style when collaborating with a team.
Simple as that!
I hope this guide has been helpful and that you now understand all the different case styles used in programming.