Naming of Classes, Methods and Member Variables
This article is not about syntax style. It’s only about right naming of classes, their methods and their member variables. Because there’s nothing better for other programmer (ie. like me) to see a constant name schema.
General Provisions
- leave out articles like ‘a’ and ‘the’ – these are totally unnecessary (TheCar)
- don’t use ‘my’ in the name – it’s not yours (myVar, MyClass)
Classes
- try to use a noun or a short phrase with a noun (Tree, SubTree)
- always use singular instead of plural
- avoid imperatively ‘object’ in class names – classes are not a objects. You can find bad examples everywhere: stdObject, ArryObject, Zend_Date_DateObject
Methods
- the name should simply describe what does the method do
- try to use a verb or verb with a noun, like save(), build(), getTitle()
Member Variables
- if type of boolean, then prepend ‘is’
- avoid variables like ‘x’, ‘i’ – use for example ‘index’
Kategorienprogramming language