You are on page 1of 9

2017­5­24 Guidelines 

to be followed by a Java Developer | JAVAbyNATARAJ

JAVAbyNATARAJ
Learn CoreJava and advanced concepts in simple steps. This blog is maintained by Nataraz sir students from DurgaSoft and SathyaTech,Ameerpeta,Hyderabad.
Home   CoreJava   Jdbc   Servlets   Jsp   Struts   Hibernate   Download   Contact Us

SEARCH THIS BLOG

Search
Guidelines to be followed by a Java Developer
>> SATURDAY, JULY 19, 2014
SUBSCRIBE VIA EMAIL

Tweet Like 7 Enter your email address:

Every java developer has to follow Subscribe

some standards to develop a good Delivered by FeedBurner

quality­software. In the Coding
standards Oracle(Sun) has given
some set of rules in java  and the
developers must follow.Standards
lead to consistency and help
software engineers avoid common
problems. A development
environment that uses Java
standards has the following
advantages:

http://javabynataraj.blogspot.in/2014/07/list­of­guidelines­to­follow­java.html 1/9
2017­5­24 Guidelines to be followed by a Java Developer | JAVAbyNATARAJ

1. Developers can view any Java software and quickly figure out what is going
on.

2. Developers new to Java are spared the need to develop a personal style.

3. Developers make fewer mistakes in consistent environments.

4. Discussions about the appropriateness of a language feature are reduced at
code reviews.

The List of Guidelines given below.

Rule 1  Always place the public class or interface in a file as the first class.
Rule 2  Always use explicit import statement.
Rule 3  Do not use numbers as words in names.
Rule 4  Do not capitalize any letter other than the first for all words in a POPULAR POSTS
name.
Rule 5  Use full English descriptors that accurately describe the DurgaSoft SCJP Notes Part-I

variable/field/class/interface. For example, use names like firstName, Download

grandTotal, or CorporateCustomer.
Rule 6  Do not remove letters from words, except to create standard short
forms. DurgaSoft OCJP(SCJP) Notes Part-II Download

http://javabynataraj.blogspot.in/2014/07/list­of­guidelines­to­follow­java.html 2/9
2017­5­24 Guidelines to be followed by a Java Developer | JAVAbyNATARAJ

Rule 7  Do not use the long form of a word when a standard short form
exists.
Rule 8  Always include units in a name when the name refers to an entity
with units.
Rule 9  Do not use acronyms in names unless the acronym is industry­ Core Java notes by Mr.Ratan from
standard or is defined in user documentation. Durgasoft
Rule 10  Always treat acronyms as words when applying other naming rules.
Rule 11  Always capitalize the first letter of class name.
Rule 12  Do not include any prefix or suffix to indicate that a name is for
Advaced Java Notes by Mr.Nataraj
any specific type.
from Ameerpeta
Rule 13  Do not include anything in a name to indicate that the name is for
a class.
Rule 14  Do not include underscores in names, except after a member’s
164 Java Interview Questions by
prefix.
Nageswara Rao
Rule 15  Do not pluralize type names except collections.
Rule 16  Use abbreviations sparingly, but if you do so then use then
intelligently and document it
For example, to use a short form for the word “number”, choose one of nbr, Download Spring material from

no or num. DurgaSoft

Rule 17  Always start a method name with a lowercase letter.
Rule 18  Always start method names with a verb.
Rule 19  Always use the following verb opposite pairs when methods Spring AOP & MVC notes by
perform opposite actions. Mr.Sekhar sir
Rule 20  Always use the method caller as the frame of reference.
Rule 21  Always include a prefix on field names.
Rule 22  Always ensure that the first letter after a field’s prefix is in Spring notes by Mr.Nataraz from
lowercase. Sathya Technologies
Rule 23  Always include white space between a keyword and an open
bracket when the keyword occurs first.
Rule 24  Always include white space before and after binary arithmetic,
Struts Flow and Architecture
equality, relational, logical, assignment, and bitwise operators.
Rule 25  Do not include white space between a unary operator and its

http://javabynataraj.blogspot.in/2014/07/list­of­guidelines­to­follow­java.html 3/9
2017­5­24 Guidelines to be followed by a Java Developer | JAVAbyNATARAJ

operand.
Rule 26  Do not include white space before the open bracket in a method
declaration, method call, open array subscript, or indexer.
Rule 27  Always include white space after a comma.
Rule 28  Always include white space after a semicolon in loop control Web Services Notes by Nataraj sir
statements. from Sathya Technologies
Rule 29  Always indent new scope three additional spaces.
Rule 30  Do not use tabs.
Rule 31  Do not ignore checked Exceptions
Rule 32  Always indent the second line and subsequent lines of a multi­line
statement an additional six spaces from the first line.
Rule 33  Always break each line of a multi­line statement immediately
following a comparison operator.
Rule 34  Always put braces around statement blocks of control statements
even if the block is empty or a single line.
Rule 35  Always align an opening brace immediately under the first
character of the corresponding keyword. BLOG ARCHIVE
Rule 36  Always align braces vertically.
►  2016 (2)
Rule 37  Do not nest if/else statements more than 3 levels deep
►  2015 (6)
Rule 38  Do not include more than one statement per line.
▼  2014 (37)
Rule 39  Do not include more than one variable declaration per line.
Rule 40  Do not use brackets when a return statement returns a simple ►  December (2)

value. ►  November (3)


Rule 41  Always put every element in an enum definition on a separate line. ►  October (4)
Rule 42  Always include a comma after the last value in an enumerated type ►  September (6)
declaration. ►  August (5)
Rule 43  Always indent the case keyword three additional spaces from the
▼  July (5)
corresponding switch statement.
Different types of Arrays in Java
Rule 44  Always comment intentional fall throughs.
Rule 45  Always indent comments at the same level of indentation as the Advanced Java-(JEE) Notes by KVR sir pdf

software being documented. Download

Rule 46  Do not use end­of­line comments.

http://javabynataraj.blogspot.in/2014/07/list­of­guidelines­to­follow­java.html 4/9
2017­5­24 Guidelines to be followed by a Java Developer | JAVAbyNATARAJ

Rule 47  Always indent end of line comments 3 characters beyond the last Guidelines to be followed by a Java


character in a statement. Developer
Rule 48  Do not vertically align end­of­line comments. DurgaSoft OCJP(SCJP) Notes Part-II
Rule 49  Do not create methods with more than seven parameters. Download
Rule 50  Always document restrictions on method parameters DurgaSoft SCJP Notes Part-I Download
Rule 51  Always check parameters for validity.
►  June (4)
Rule 52  Always use exceptions when an invalid parameter is found in a
►  May (2)
non­private method.
►  April (1)
Rule 53  Always use assertions with information expressions to check for
invalid parameters private methods. ►  March (2)

Rule 54  Do not place a return statement anywhere except as the last line ►  February (1)


of a method. ►  January (2)
Rule 55  Do not use a return statement in a method that returns void. ►  2013 (18)
Rule 56  Do not use a method's return value to indicate that an unexpected
►  2012 (29)
error occurred in the method.
►  2011 (86)
Rule 57  Do not make any member variables public.
►  2010 (17)
Rule 58  Always declare fields before methods or constructors in a class
Rule 59  Always order field declarations based on their access specifier ►  2009 (17)

Rule 60  Always declare constructors before any other method, starting with
the default constructor if applicable.
Rule 61  Always use an initializer when a member variable is always
initialized to the same value.
Rule 62  Always override Object.toString() in a user­defined class.
Rule 63  Do not overload operators unless it is completely obvious what the
operator does to the class.
Rule 64  Always override hashCode when you override equals
Rule 65  Do not compare boolean values to true or false to create Boolean
expressions.
Rule 66  Do not hardcode strings that are presented to end users.
Rule 67  Always use the form: Type[] name to define an array
Rule 68  Do not use interfaces to define a “constant interface”.
Rule 69  Always comment when a cast is used to convert between value

http://javabynataraj.blogspot.in/2014/07/list­of­guidelines­to­follow­java.html 5/9
2017­5­24 Guidelines to be followed by a Java Developer | JAVAbyNATARAJ

types.
LABELS
Rule 70  Always use the method equals to compare objects for equality.
ActionServlet (1) Advantages (1) AdvJavaBooks (7) Ajax
Rule 71  Always use enhanced for loop for simple loop implementations (1) AOP (1) Architecture (2) ArrayList (1) Arrays (4)
Atlassian (2) Basic Java Programs (1) Basic JavaPrograms
Rule 72  Always postpone variable definitions as long as possible. (1) BufferedReader (2) ClassNotes (2) Coding Standards
Rule 73  Do not use the same variable for multiple purposes. (1) Collections (20) Con guration (3)
Rule 74  Do not modify a loop index variable inside a for loop. ConnectionPooling (1) CoreJava (67)
CoreJavaBooks (10) CSV File (1) CVS (2) DAO (1)
Rule 75  Do not create more than one main method in a single package Database (1) DataStructure (1) Decorative (1)
Rule 76  Every switch statement should include a default case. The break in Designpatterns (6) Developer (1) Differences (2)

the default case is redundant, but it prevents a fall­through error if later Downloads (55) DurgaSir Notes (2)

another case is added. DurgaSoft (6) eBooks (42) Eclipse (1)


Examples (5) Exceptions (1) File I/O Operations (1) File
Rule 77  Always make members,  local variables and parameters final when Operations (2) FishEye (1) Frameworks (6) Generics
possible. (2) HashMap (2) HeadFirst (5) Hibernate (16)
HibernateBooks (3) How To (2) Html (2) Html5 (1)
Rule 78  Do not use literals.
Installations (1) Interview Questions (13) IO
Rule 79  Do not modify a variable on the same line it is used as a condition Package (14) IOC (1) j2ee (7) java (32) Java 5
or array subscript. Features (4) Java Programs (2) Java Standards (1) java.io
(1) java.util (1) JavaBeans (1) JavaScript (1) JavaTips (1) jdbc
Rule 80  Avoid local declarations that hide declarations at higher levels. For (13) JIRA (1) jQuery (1) JS (1) Jsp (7) JSTL (2) KVR Sir (1)
example, do not declare the same variable name in an inner block. List (1) Maven (1) MS Access (2) mvc (7) MyEclipse (4)
Nataraz Sir Notes (4) Normalization (1) OCJP (6) Oracle
Rule 81  Comments should add to the clarity of code. Avoid decoration, i.e., (1) Others (1) Prepared Statement (1) Products (1)
programs (6) Projects (1) Promotions (1) RealTime_Tips
do not use banner­like comments and use single line comment and multiline (4) Re ection (1) RegEx (1) SathyaTech (1) Scanner (2)
comments.Document why something is being done, not just what. scjp (5) Sekhar sir Notes (6) Server (1) Servlets (9)
Settings (1) Spring (6) SQL (1) Statements (2) Static
Rule 82  Always write Javadoc comments for packages, interfaces, classes, Import (1) Streams (1) Strings (3) Struts 1.2 (29)
methods, return values, exceptions that are thrown. Struts2 (1) StrutsBooks (2) Synchronization (1)
Synchronized (1) Threads (3) Tomcat (3) Tools (1) Util
Rule 83  Always document the circumstances under which each exception pack (5) Var-Args (2) weblogic (3) WebServices (3)
can be thrown using the Javadoc @throws clause. WSAD (2) XML (1)

Rule 84  Always add the "Exception" suffix to the name of types derived
from java.lang.Exception.
GOOGLE+ FOLLOWERS
Rule 85  Always declare each checked exception that can be thrown
Muralidhar Nayani
individually
Add to circles
Rule 86  Always throw unchecked Exceptions if the error is not recoverable
by the caller.
Rule 87  Always include failure information in an Exception detail message
that contains the values for all parameters and fields that contributed to the 286 have me in circles View all

http://javabynataraj.blogspot.in/2014/07/list­of­guidelines­to­follow­java.html 6/9
2017­5­24 Guidelines to be followed by a Java Developer | JAVAbyNATARAJ

exception.
Rule 88  Do not use assertions in non­private methods.

If you found any mistake or wrong statement from the above, please
comment below to correct it.

Reference Books:

Core JAVA : An Integrated Approach 1 Edition

Core Java : Advanced Features (Volume ­ 2) 8 Edition

Core JavaServer Faces 3 Edition

SCJP Sun Certified Programmer for Java 6 Study Exam 310

Posted by Muralidhar Nayani at Saturday, July 19, 2014 2 Comments 
Labels: Coding Standards, CoreJava, Java Standards

2 Comments JAVAbyNATARAJ 
1 Login

  Recommend ⤤ Share Sort by Best

Join the discussion…

Affity Solutions • 3 years ago
Thanks for your ideas. You can also find the details on Affity Solutions, at the
Java Developers. The main object of the Affity Solutions is to provide quality
web services and is among the few software development company in Nagpur.
△   ▽ • Reply • Share ›

Mdhar  GeekDude  •  3 years ago

As per Jim Halvorsen comment i have corrected some of the points and
modified the title from 'rules' to Guidelines'. Thanks Jim.
http://javabynataraj.blogspot.in/2014/07/list­of­guidelines­to­follow­java.html 7/9
2017­5­24 Guidelines to be followed by a Java Developer | JAVAbyNATARAJ
modified the title from 'rules' to Guidelines'. Thanks Jim.
△   ▽ • Reply • Share ›

ALSO ON JAVABYNATARAJ

Default value of primitive data types Static Import in Java with an
in Java Example
1 comment • 2 years ago• 1 comment • 2 years ago•
Ginger Sanches — Now I understand Jumbodium  — Informative share.
the main process of working of Liked the post. Thank u for the
primitive type of Java. Even if … share.

July 2014 Best practice to find Duplicate
1 comment • 3 years ago• Character from a String in java
Siddu Siddharth — 2 comments • 2 years ago•
ieeeprojectshub.blogspot.in Mdhar — make sure all your jars with
versions are configured properly.If
you provide your …

✉ Subscribe d Add Disqus to your siteAdd DisqusAdd � Privacy

Newer Post Home Older Post

FRIENDS LINKS STRUTS POSTS POPULAR POSTS

javac.in Basic Struts Login Application
DurgaSoft SCJP Notes Part­I Download
Web DevelopmentTips,Tutorials & Books struts­config.xml in Detail
What  are  the  Different  types  of DurgaSoft  OCJP(SCJP)  Notes  Part­II
ABOUT AUTHOR
FormBeans in Struts? Download
Muralidhar Nayani How  ActionServlet  acting  as  a
Hi  this  is  Muralidhar,  i  am  living  in FrontController Core  Java  notes  by  Mr.Ratan  from
Chennai. I have been working in Java and Struts configuration file Durgasoft

http://javabynataraj.blogspot.in/2014/07/list­of­guidelines­to­follow­java.html 8/9
2017­5­24 Guidelines to be followed by a Java Developer | JAVAbyNATARAJ

JEE  technologies.  I  like  to Struts  ApplicationResource.properties  in


Advaced  Java  Notes  by  Mr.Nataraj  from
share  the  java  programs Detail
Ameerpeta
and  materials  from  different Struts DispatchAction Example Application
institutes  and  free  eBooks
Struts  LookupDispatchAction  Example 164  Java  Interview  Questions  by
to download.
Application
Nageswara Rao
View my complete profile Simple Struts program Using Tiles
Simple  Application  using  DispatchAction Download Spring material from DurgaSoft
and Tiles in Struts

© javabynataraj.blogspot.com from 2009 ­ 2014. All rights reserved.

http://javabynataraj.blogspot.in/2014/07/list­of­guidelines­to­follow­java.html 9/9

You might also like