• 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
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Using try-catch for program logic.  RSS feed

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am reading about reflection at the moment. In the book the following example is given. It shows a method which tries to locate
a method defined by its name and type of its arguments for a specified class. It first looks to see if the method is a declared method in the class
and otherwise traveses the inheritance-tree above it, to see if it has inherited the method:


Is it generally ok coding to use try-catch for the purpose of handling program "flow" ?
 
Sheriff
Posts: 67260
170
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you think? Does it add to the clarity of the code? Is there a simpler way to accomplish the same thing?
 
Marshal
Posts: 64494
225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And is NoSuchMethodException the most appropriate class if null is passed?
 
Tim McMurry
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

thanks for the inputs. I get new homework by asking a question, when is it due ?!
I am reading up on the exception-handling mechanism to come up with qualified arguments against. To my beginner-eyes
it seems at first that it would be hard writing the code so compactly without using try-catch.
It might be time for learning to use a profilimg tool to compare the time usage for the method using try-catch with a rewritten version of it.
Only problem is, I love the commandline and think IDE's are for when you have learned enough to be able to do by hand everything your IDE can.
But there doesnt seem to be many options for commandline profiling
 
I will suppress my every urge. But not this shameless plug:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!