OOP Naming Conventions
- Category: web development
When programming object-oriented programming (OOP) a standard naming scheme for classes, objects, variables, and methods is important. Here are two naming schemes I know of (I generally use the second one):
Naming Scheme 1:
a. Class name: concatenated words, each word should start with uppercase.
§ E.g: Database, Person, BankAccount, MyLinkedList etc…
b. Objects, variables, methods: concatenated words, first word all lowercase, subsequent words should start with uppercase.
§ E.g (objects): $array = new Array(), $myAccount = new Account();
§ E.g (variables): $i, $nodeList, $myCounter;
§ E.g (methods): deposit(), getName(), setName(), getAccountNumber();
Naming Scheme 2:
a. Class name: concatenated words, each word should start with uppercase.
§ E.g: Database, Person, BankAccount, MyLinkedList etc…
b. Methods: concatenated words, first word all lowercase, subsequent words should start with uppercase.
§ E.g: deposit(), getName(), setName(), connectDatabase();
c. Objects, variables: all lowercase concatenated words separated by underscores.
d. Constant variables: all uppercase concatenated words separated by underscores.
§ E.g: $PI = 3.14, $GRAVITY = 9.8, $ARRAY_SIZE = 50, etc…
Very Interesting post! Thank you for such interesting resource!
PS: Sorry for my bad english, I’v just started to learn this language
See you!
Your, Raiul Baztepo