Following well defined coding guidelines is very important for a team (two or more developers). Proper coding guidelines help team members to understand the code written by other developers and thus improve efficiency of the team.

Although all teams develop their own coding guidelines, there is some basics that will always stick. You can define if you want to use camelCase or snake_case but many times, developers find it difficult to understand the meaning of different cases. So in this article, we are going to define different cases used in programming.

Snake_case

It have all the words in lower case and different words are separated by underscore (_). It is mainly used used and popular in wordpress and old PHP projects. Examples:


$first_name;
$last_name;
$public_path;
$account_number;

Spinal-case or kebab-case or lisp-case

spinal-case or kebab-case or lisp-case, all are different names for this style. It is similar to snake case but in place of underscore, we use hyphen (-). It is mainly used in SEO firendly URL but not popular in coding. Examples:


$first-name;
$last-name;
$public-path;
$account-number;

SCREAMING_SNAKE_CASE

Similar to snake_case but all letters are in upper case. It is mainly used to define constants. Examples:


$DAYS_OF_WEEK;
$FIRST_DAY_OF_WEEK;
$DATE_FORMAT
$DEFAULT_PAGE

CamelCase

It is used to define method and variable names. Here first letter of every word is capital except first word. Examples:


// Variables
$firstName;
$lastName;
$publicPath;
$accountNumber;

//Method names
getFirstName()
setLastName()
getPublicPath()
getAccountNumber()

PascalCase

Similar to camel case but first letter of first word is also capital. It is used to define name of class and interface. Example:


class UserProfile {}
interface UserInterface {}