Naming convention:
A naming convention is a rule to follow as you decide what to name your identifiers
(e.g. method,class, package,variable,etc.), but it is not mandatory to follow that is why it is known as convention not rule.
Advantage of Naming Convention:
By using standard Java naming conventions they make their code easier to read for themselves and
for other programmers. Readability of Java code is important because it means less time is spent trying to figure out what the code does.
Example:
class name: should begin with uppercase letter and be a noun e.g.Object,System,Thread,String etc.
Interface name: should begin with uppercase letter and be an adjective. e.g.
List, Set, Runnable, Collection etc.
method name: should begin with lowercase letter and be a verb .e.g. toString(), main(),
print(), println() etc.
variable name: should begin with lowercase letter e.g. firstName, orderNumber, lastName etc.
package name: should be in lowercase letter. e.g. lang, java,util, io, sql etc.
constants name: should be in uppercase letter.
e.g. MIN_PRIORITY, GREEN, YELLOW, MAX_PRIORITY etc.
A naming convention is a rule to follow as you decide what to name your identifiers
(e.g. method,class, package,variable,etc.), but it is not mandatory to follow that is why it is known as convention not rule.
Advantage of Naming Convention:
By using standard Java naming conventions they make their code easier to read for themselves and
for other programmers. Readability of Java code is important because it means less time is spent trying to figure out what the code does.
Example:
class name: should begin with uppercase letter and be a noun e.g.Object,System,Thread,String etc.
Interface name: should begin with uppercase letter and be an adjective. e.g.
List, Set, Runnable, Collection etc.
method name: should begin with lowercase letter and be a verb .e.g. toString(), main(),
print(), println() etc.
variable name: should begin with lowercase letter e.g. firstName, orderNumber, lastName etc.
package name: should be in lowercase letter. e.g. lang, java,util, io, sql etc.
constants name: should be in uppercase letter.
e.g. MIN_PRIORITY, GREEN, YELLOW, MAX_PRIORITY etc.
No comments:
Post a Comment