The naming conventions are a set of rules that the developers have to fallow while writing the code. These rules decide what to name your identifiers such as packages, interfaces, classes, variables, constants and methods. While giving the names to these identifiers we should fallow these conventions given by sun Microsystems.
The fallowing are the areas where we have to fallow the naming conventions:
Class name: A class name should be meaningful and always it should start with uppercase letter. If the class name is the combination of two or more words then every word first letter should be in uppercase and we should see that there should not be any spaces or special characters except underscore in between the class name.
e.g. String, Color, Button, System, Thread etc.
Interface name: The interface names also fallow the same naming conventions as that of class.
e.g. Runnable, Remote, ActionListener etc.
Package name: unlike class name or interface name the package name always should start with lowercase letters.
e.g. java, lang, sql, util etc.
method name: A method name should start with lowercase and if the method name is a combination of two or more words then the second word onwards every word first letter should be in uppercase.
e.g. actionPerformed(), main(), print(), println() etc.
variable name: A variable name should start with lowercase in all the cases.
e.g. firstName, orderNumber etc.
constants name: The constants should be declared in uppercase.
e.g. RED, YELLOW, MAX_PRIORITY etc.
The fallowing are the areas where we have to fallow the naming conventions:
Class name: A class name should be meaningful and always it should start with uppercase letter. If the class name is the combination of two or more words then every word first letter should be in uppercase and we should see that there should not be any spaces or special characters except underscore in between the class name.
e.g. String, Color, Button, System, Thread etc.
Interface name: The interface names also fallow the same naming conventions as that of class.
e.g. Runnable, Remote, ActionListener etc.
Package name: unlike class name or interface name the package name always should start with lowercase letters.
e.g. java, lang, sql, util etc.
method name: A method name should start with lowercase and if the method name is a combination of two or more words then the second word onwards every word first letter should be in uppercase.
e.g. actionPerformed(), main(), print(), println() etc.
variable name: A variable name should start with lowercase in all the cases.
e.g. firstName, orderNumber etc.
constants name: The constants should be declared in uppercase.
e.g. RED, YELLOW, MAX_PRIORITY etc.
No comments:
Post a Comment