Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

conventional program control

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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