Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception Design

 
Santhosh Kumar
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have started new project and I need to design the application. I was thinking, what is the best design we can choose to meet the utmost performance requirement along with robust exception handling.
If you have any info, pl pass it on.
 
Mark Herschberg
Sheriff
Posts: 6037
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did I understand you right? You just asked, "how can I make a good design, and incorporate exception handling?" This is a really big question, and one that's not easy to answer.
It's also not J2ME related.
--Mark
 
Santhosh Kumar
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, if I had asked for lots in one question. Here is what I'm looking for. Good exception design guidelines keeping performance in mind. For ex., don't throw many exceptions, always write the stack trace into the log etc...
thanks
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
e.printStackTrace() doesn't count as handling an Exception
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Utmost performance" is not a reasonable requirement, because you can't say wether you have met it or not. Also, "utmost performance" inevitably comes with "utmost project costs", so it probably isn't what your client(s) really want(s).
And even when you have a more reasonable requirement (such as "has to process xxx in less than yyy seconds", for example), remember the Three Rules Of Optimization:
1. Don't.
2. (for experts) Don't - yet.
3. (if you really need to) Use a profiler to find the bottleneck - it isn't where you think it is.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
e.printStackTrace() doesn't count as handling an Exception
Maybe not, but (a) it's far better than catching an exception and doing nothing with it, which is what many novices end up doing, and (b) it's perfectly reasonable in addition to other actions. Logging exceptions doesn't preclude doing other things as well (including re-throwing the exception). And in any situation where you're not entirely sure yet what an appropriate response is, logging will at least give you ongoing reminders of what's really going on in your program.
 
Max Habibi
town drunk
( and author)
Sheriff
Posts: 4118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as exception handling and logging go, you might find that jdk 1.4 offers some nice options, including exception chaining.
M
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic