naming in programming

Class and Method Naming

Class name should be a noun (User, Post). Method name should be a verb (create, activate).

Class names should always start with an uppercase letter.

1
2
3
4
5
6
7
8
9
class Class_name {
 
 
 
    function get_file_properties() {} // descriptive, underscore separator, and all lowercase letters
 
 
 
}

Variable Names

Variables should contain only lowercase letters, and be reasonably named to indicate their purpose and contents. Very short, non-word variables should only be used as iterators in for() loops.

1
2
3
4
5
6
7
8
9
for ($j = 0; $j < 10; $j++)
 
$str
 
$buffer
 
$group_id
 
$last_city

Leave a Comment