Programming 👩‍🍳 Naming and code writing conventions

Share on email
Share on twitter
Share on linkedin
Share on facebook
Article the naming conventions in programming: Camel case, Pascal case, kebab case, snake case and underscore case by wpr0ck
Article the naming conventions in programming: Camel case, Pascal case, kebab case, snake case and underscore case by wpr0ck
Article the naming conventions in programming: Camel case, Pascal case, kebab case, snake case and underscore case by wpr0ck
Article the naming conventions in programming: Camel case, Pascal case, kebab case, snake case and underscore case by wpr0ck
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 advantage of making it easier for developers to find the names used in a project (both to name them and to call them) and to collaborate more easily when a code is written with several people. In all cases, it is advisable not to use accents or special characters (except in special cases, such as the jQuery framework which uses the dollar symbol "$" to name its main class).

Conventions : The Camel case

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

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 in Twitter hashtags. 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.

😎 The high-end WordPress host everyone's talking about

Conventions : The Pascal case

Convention: 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 hyphens (-).

Examples: my-variable-name, my-url

The kebab case is recommended for writing URLs as well as 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.

😻 The unlimited WordPress host. Used and validated by wpRock.fr

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

The underscore 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 conventions in WordPress

You can find the conventions and best practices of programming for the themes, the pluginsand the core WordPress documented in the codex.

Julien MA Jacob
WordPress Developer
Julien MA JACOB - WordPress Developer
Passionate about the web and programming with always many projects in mind
  Discussion of the article

2

avatar
1 Comment threads
1 Thread responses
0 Subscribers
 
Comment with the most reactions
The most popular comment
2 Commentary Authors
Julien MA JacobGUY Jérôme Recent commentators
  Subscribe to the newsletter  
most recent oldest one most popular
Notify to
GUY Jérôme
Guest
GUY Jérôme

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

Julien MA Jacob
Guest
Julien MA Jacob

Hello Jérôme,
Thank you for these clarifications.
I will see to eventually add them to the article:)