Coding Standards and Naming Conventions
Coding Standards and Naming Conventions
Naming Conventions
Suggested by- Sun (Now Oracle)
Coding Standards and Naming
conventions
• Let us understand some of the important coding standards
and naming conventions.
• Coding standards (CS) and Naming conventions (NS) are
suggestions given by sun. CS and NS help developers to
develop project with more readability and understandability.
• Why Coding Standards?
Coding Standards and Naming
conventions
• A program is written once, but read many times
• During debugging
• When adding to the program
• When updating the program
• When trying to understand the program
• Anything that makes a program more readable and
understandable saves lots of time, even in the short run
Coding Standards and Naming
conventions
Naming Conventions
• Naming a Class:
• Class name should be “Noun” , because it represents
things.
• Class name should be in title case, “every word first
letter should be capital letter”
• Example- Person, EmployeeNumber, PrintStream
Coding Standards and Naming
conventions
• Naming Variable:
• Variable name also should be “noun” because it represents
values.
• In variable name, “first word first letter should be small,
and after that every word first letter should capital”.
• Example- userName, password,
• In final variable all its letters should be capital and words
must be connected with ‘_’.
• Example- MIN_BALANCE, PI.
Coding Standards and Naming
conventions
• Naming methods:
• Method name should be “verb”, because it represents
action.
• In method name, “first word first letter should be small,
and after that every word first letter should be capital and
should follow ( )”.
• Example- getUserName(), getBalance(), findArea().
Coding Standards and Naming
conventions
• Naming package:
• All letters are small, and its length should be as short as
possible.
• Example- io, lang, util, beans.