aspose file tools*
The moose likes Java in General and the fly likes Java coding/debugging check list Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java coding/debugging check list" Watch "Java coding/debugging check list" New topic
Author

Java coding/debugging check list

Linda Xu
Ranch Hand

Joined: Feb 14, 2000
Posts: 51
Hi, All
I am a java programmer.
In my job, I found most of the bugs(except the logic mistakes in the design) are very common, for example: missing a parenthesis, cast an object into another uncompatible type, ...
So I want to make a check list for java programmers, in which I lisk all the common mistakes, so when we coding we can try to avoid them, and when we have some compiling / running time error, we can also use this check list help us to find the bug.
Followed is my check list, please give me any suggestions of yours.
Java Programmer Check List
1.match the parenthesis
2.initialize the variables
3. use �equals� to compare two objects
use �==� to compare two primitive variables
4.every line ended by ;
5.the instance variable have the scope as �private�
6.use constant to avoid the magic number
7.include all the required library
8.catch the exception
9.deep copy of an object (clone)
10.cast an object to another type
11.have a return command if the method have some return type.
12.flush and close a file after write data into it
13.use & and && correctly

Thanks!
Nura Horne
Ranch Hand

Joined: Jul 26, 2001
Posts: 40
Is this not a moot point as any good Java compiler will tell you the error using pretty much the same language you use in your list!
If you want to compile such a list, go to the Sun website, get the Java Language Specification, goto the section of Compiler errors (or similar) and select from that documentation the errors you want to list.
Hope this helps, A
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Well, many of these are caught immediately by the compiler. But not all - 3, 5, 6, 9, 12, and to some extent 13 are generally not caught by the compiler, and often not by immediate runtime errors either. They are things you need to be aware of and decide for yourself if they apply in a given situation, in order to get the results you expect.

"I'm not back." - Bill Harding, Twister
 
 
subject: Java coding/debugging check list