File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes what each part of this program does Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "what each part of this program does" Watch "what each part of this program does" New topic
Author

what each part of this program does

jake bellhorn
Greenhorn

Joined: May 03, 2006
Posts: 24


ive tried to comment on things in the program that i knew, im not sure if i got them right, what other key things in this program should i comment on, what do they do?
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

When commenting a program, we usually try to not overcomment it. Obvious things should not be commented.
You have written : // clac is the name of the class
First, you've got the wrong class name in your comment (no big deal). But, no comment is better than a bad comment
Second, such obvious things do not need to be commented.


[My Blog]
All roads lead to JavaRanch
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Labeling variables is a start. But if you want to take this code apart to understand how it really works, I suggest that you look at each class separately. In other words, understand the different types of objects that work together in this program, examining their methods to understand what each class does.

Once you have the pieces figured out, then work through the path of execution -- looking at what is called when.

Also, there are depreciated methods here. If you compile with...

javac -Xlinteprecation PocketCalc.java

...you will generate a list of the depreciated methods. You should check the API to see what these methods have been replaced with.
[ June 20, 2006: Message edited by: marc weber ]

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41823
    
  63
Is this a piece of code you found somewhere on the net, and are thinking about turning in for an assignment of yours?


Ping & DNS - my free Android networking tools app
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

jake, here again, you need to at least cite your source, since this code is copyrighted material...

http://www.df.lth.se/~mikaelb/PocketCalc/PocketCalc.java

(If this was submitted as an assignment, I expect a professor would recognize the code was not written in "modern" times, given the depreciated awt methods. A quick search of the internet would find several examples of this exact code.)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what each part of this program does