• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

conventional program control

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,
Why should exception-handling techniques not be used for conventional program control?
Thanks

Larry
 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can think of two reasons off the top of my head:
1) Using exceptions for flow control basically means that you are using exceptions as a goto mechanism, and gotos make for messy, spaghetti code.
2) Creating and catching an exception brings overhead of creating an object. This is much slower and more expensive than using standard flow-control.
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bruce Eckel's book, Thinking In Java, chapter 9 on Error Handling with Exceptions is worth reading. You can find it on-line at http://www.codeguru.com/java/tij/tij0096.shtml or you can download the entire book from http://www.bruceeckel.com
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Some design and program flow considerations are also discussed in the Exception Handling section of Sun's Java Tutorial.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And to pad my stats with three posts for one answer...
Try a search on google for things like "Exception Handling Philosophy Java". You're likely to turn up some interesting articles.
And you might want to try a search through JavaWorld's articles.
Good Luck.
 
reply
    Bookmark Topic Watch Topic
  • New Topic