Programming 🎀 Naming and code writing conventions

Share on email
Share on twitter
Share on linkedin
Share on facebook
Share on twitter
Share on linkedin
Share on facebook
Share on whatsapp
Share on email

Explanations with examples of the most common naming conventions in programming: Camel case, Pascal case, kebab case, snake case and underscore case.

Naming conventions homogenize code, which has the advantages of making it easier for developers to find the names used in a project (both to name and to call them) and to collaborate more easily when code is written in a group. In all cases, it is advisable not to use accents or special characters (except in special cases, such as the jQuery framework that uses the dollar sign "$" to name its main class).

Conventions : The Camel case

Convention: the words are linked without spaces. Each word begins with a capital letter except the first one.

Examples: myVariableName, myUrl

It's probably the most widely used convention. It can be found in JavaScript, Java, C++, C# and much more. It's also the most common form of hashtags Twitter. This convention is also used by some brands to display their belonging to the digital world as it is the case for eBay and iPhone. When using acronyms (URL, CSS, HTML, etc...) in Camel Case, only the first letter of the acronym should be capitalized.

Conventions : The Pascal case

Convention: the words are linked without spaces. Each word begins with a capital letter.

Examples: MyVariableName, MyUrl

This convention is used in the Pascal programming language or to name classes in PHP.

As with the Camel Case, only the first letter of acronyms are capitalized. This convention is also used by some brands to communicate an innovative aspect such as PlayStation, QuickTime or MasterCard.

Conventions : The Kebab case or Spinal case

Convention: the words are in lower case and are linked by dashes (-).

Examples: my-variable-name, my-url

The kebab box is recommended for writing URLs as well as for naming images, PDFs and other files for the web. In programming, it is used for example to name classes and IDs in HTML and CSS code.

The name Kebab case actually refers to the kebabs more than to the kebabs themselves, like a word skewer made of dashes. As for Spinal case, it refers to the spinal column.

Conventions : The Underscore case or Snake case

Convention: words are in lower case and are linked by underscores (lower dash: _).

Examples: my_variable_name, my_url

Theunderscore case, also called snake case, is used in PHP, Ruby and Phyton. There is a variant of this convention. Named screaming snake case, which consists in putting all words in uppercase, always separated by underscores (Example: MY_CONSTANT_NAME). We find this form in the names of constants in PHP or to name exceptions in ADA.

Programming agreements under WordPress

You can find the conventions and good programming practices for the themes, the plugins and the core WordPress documented in the codex.

Julien MA Jacob
Developer WordPress
Julien MA Jacob - Developer WordPress
Passionate about the web and programming with always a lot of projects in mind
  Discussion of the article
Subscribe to our newsletter
Notify of
guest
2 Comments
most popular
latest oldest
Inline Feedbacks
View all comments
GUY JĂ©rĂ´me

Good article!
A precision on Camel Casing and Pascal Casing :
- What is presented here under Camel Casing is what corresponds to Lower Camel Casing
- The Pascal Casing is actually Upper Camel Casing.

Julien MA Jacob

Hello, Jerome,
Thank you for that clarification.
I will see if I can add them to the article :)