Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About doc and exception

 
Ray Cheeny
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
1>
javadoc style comments must be used for each element of the public interface of each class

What does it mean?
Need I comment all the classes and methods?
When I use javadoc ,should I comments all the methods ?
2>I have a TextArea which will show the excepions in the user interface and I will still throw it to the MS-DOS,too.Is that right?
If there's exception occured in server,how should I to catch it?Show a Dialog or just throw it?
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ray,

What does it mean?
Need I comment all the classes and methods?
When I use javadoc ,should I comments all the methods ?

Well that's a good question. What it means in the strictest sense is that all public identifiers, methods and variables must be javadocked (still not sure abou that word ). I javadocked everything but I lost a point on documentaion so who knows? I feel that at the very least, you should javadoc all public and protected identifiers.

2>I have a TextArea which will show the excepions in the user interface and I will still throw it to the MS-DOS,too.Is that right?

I didn't and don't really see any point in throwing back to the shell. Just let the user know in the GUI.

If there's exception occured in server,how should I to catch it?Show a Dialog or just throw it?

If you have a server GUI, then do it the same way you did in the client. If not then wrap the exception with a meaningful message and throw it back to the shell.
Hope this helps,
Michael Morris
 
Ray Cheeny
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Michael,
I have almost come to the end of my Developer Assignment.But some places have a little confusion.
As what you have told me I would javadoc all the methods .
About the exception,when I catch the exception,should I use the e.printStackTrace() or
System.out.println(e)?I think the latter is better,for the formmer print too many messages and
is not suitable for user to see those.How do you did it?
If not then wrap the exception with a meaningful message

What is the meaningful message?
Do you mean when an remoteException is throwed,I should tell user a string like "Cannot connect to the server" instead of "java.net.connectionException...."?
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you mean when an remoteException is throwed,I should tell user a string like "Cannot connect to the server" instead of "java.net.connectionException...."?

Yes he does mean that.
I would use e.printStackTrace() but only for my debugging, you can still have that display in the console window. But the best solution for exceptions displaying to users is through a simple JOptionPane window in Swing that pops up and gives a nice pretty easy to understand message, like the one you said above.
If you don't have a GUI for the server, which is fine, you will probably use e.printStackTrace to the servers console window.
Good Luck
Mark
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic