StudlyCase VS camelCase VS snake_case

These three are types of naming conversions used to declare variables, constants, functions and classes names.

Studly Case

StudlyCaseWords Also called Pascal Case which makes the first letter of each word capital with no space or underscore between words.

Used in

Usually this type of naming conversion used with class names in OOP in general

// php
class MyClassHandler {}

// js

class MyClassHandler {}

Camel Case

camelCaseWords

In this name conversion the first word is lower case and starting from the second word first letter MUST BE capitalized.

Used in

Usually this type of naming conversion used with class members properties and methods

// php
class MyClass 
{
    public $propertyName;

   public function methodNameAsEachWordIsCapitalizedExceptTheFirstWord()
  {
      // ...
  }
}

Snake Case

snake_case_words

All words are written in lower cased separated with underscore _.

Used in

Usually this type of naming conversion used with variable and function names

// php
$user_first_name = 'Hasan';

function get_user_info()
{
   // ...
}

Bonus

Almost in most of programming languages constants are written in UPPER_SNAKE_CASE way.

Example

const USER_ACCOUNT_TYPE = 'admin';
smackdown#smackdown

Comments (5)

Ghada SaidAhmed
Ghada SaidAhmed
8 months ago

should i use Snake Case with variable or my be use Camel Case ?

Mohamed Samir
Mohamed Samir
8 months ago

good

heba taha
heba taha
8 months ago

great

Mohamed Aboelmaged
Mohamed Aboelmaged
8 months ago

good to know

Mohamed  Eltahawy
Mohamed Eltahawy
8 months ago

Nice Post