Java coding standard

1. Whenever we are writing Java code it is highly recommended to follow coding standard.Whenever we are writing any component its name should reflect the purpose of that component(functionality).

2. The main advantage of this approach is readability and maintainability of the code will be improved.

coding standard for classes:

String

StringBuffer

Account

Dog

etc...

* Usually classes names are nouns, should start with Uppercase character and if its contains multiple words every innerword should start with Uppercase Character i.e follow camelcase rule.

coding standard for interface:

Runnable

serializable

Comparable

etc...

* Usually interface names are adjective, should start with Uppercase character and if its contains multiple words every innerword should start with Uppercase Character i.e follow camelcase rule.

coding standard for method:

print()

sleep()

run()

main()

start()

etc...

* Usually method names are either verb or verb-noun combination, should start with Lowcase character and if its contains multiple words every innerword should start with Uppercase Character i.e follow camelcase rule.

coding standard for variables:

name

age

salary

mobileNumber

etc...

* Usually variables names are nouns, should start with Lowcase character and if its contains multiple words every innerword should start with Uppercase Character i.e follow camelcase rule.

coding standard for constants:

MAX_VALUE

MAX_PRIORITY

NORM_PRIORITY

MIN_PRIORITY

PI

etc...

* Usually constants names are nouns, should contain only Uppercase character and if its contains multiple words than this words are separated with Underscore(_) symbol.

Note:Usually we can declare constant with public,final and static modifiers.










NEXT PAGE



PREVIOUS PAGE