- Classes and Interfaces
Classes names should be nouns. For one worded classes, first letters should be capitalized. If two or more words are linked together to form the name, the first letter of the succeeding words should be capitalized (Billing + File = BillingFile).
Examples:
For Interfaces, names should be adjectives.Header Details Flowers BillingFile
Serializable Runnable
- Methods
Method names should be in verb-noun combination. Format should be in camel case (camelCase) where first word should be in lower case and the first letter of the succeeding word/s should be in capital.
Examples:Header getSum convertFile formatNumber computeBillingAmount
- Variables
should also be in camelCase
Examples:frameHeight billSummary accountName temp
- Constants - Java constants are variables marked as static and final. They
should be named in uppercase with underscore as separators.
Examples:ENCRYPT_KEY MIN_WIDTH MAX_HEIGHT ITERATOR
Linggo, Hulyo 28, 2013
Java Coding Standards
Sun
estimates that on a typical lifetime of codes, creation and testing of codes
consumes only 20%, and the remaining 80% efforts will go to maintenance and
enhancement. Also, hardly any software is maintained for its whole life is
maintained by its author. Thus, Sun set standard convention that they follow
and encourage other Java programmers to improve readability of the codes of software,
allowing programmers to understand new code easily (that others have written), and reduce the effort focused on testing,
maintaining and enhancement of any piece of code.
Mag-subscribe sa:
I-post ang Mga Komento (Atom)
Walang komento:
Mag-post ng isang Komento