- 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.
Biyernes, Hulyo 26, 2013
Java Identifier
A Java identifieris any name in a Java program that are used to define a package, class, interface, method, or a variable. But technically, these identifiers must be composed of Unicode characters, numbers, currency symbols and connecting characters.
The following are the
rules in declaring a Legal Java Identifier.
- Identifiers must start with a letter, a currency character ($), or a connecting character such as the underscore ( _ ). It can not start with a number.
- After the first character, identifiers can contain any combination of letters, currency characters, connecting characters, or numbers.
- There is no limit to the number of characters an identifier can contain.
- Java reserved words are not to be used.Check this list of Java Keywords to not be used in declaring identifiers.
- Identifiers in Java are case-sensitive.Variable SUM and sum are different when being read by the Java Compiler.
Examples of legal Identifier
int weight;
int $money;
int _temp;
String _$;
String _temp_container;
String a_very_long_name_for_an_identifier;
String label01;
Examples of illegal identifier;
int .hh;
double money.sum;
int :identifier;
int -c;
int f#;
int 01label;
String volatile;
Huwebes, Hulyo 25, 2013
Birth of Java Novice
Hi! I am Wilma and a Java Novice. I am a Java Programmer by now and planning to take Sun Certified Java Programmer (SCJP) exam. I am taking my time to learn each syntax and structures that I need to learn. But as I have my review, I realized that I am still a novice in Java Programming. Java is such a gem, and there are hidden treasures in it that I have not utilized and learned yet. So here, I decided to make a blog on how I take my knowledge in Java into a deeper, higher and wider level and hopefully share my steps on my SCJP certification goal!
Mag-subscribe sa:
Mga Post (Atom)