• 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

Exception in if statement: if/else vs. if - which is better?

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,
Need your opinion on this:
Which is more preferred and why?
thanks,
derek
 
Ranch Hand
Posts: 319
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My gut feeling is that this one is better:

Why? Because exceptions is for when normal flow of execution fails. I.e. Something is wrong, and we can't continue.
But if nothing is wrong, just carry on as if there was no check.
Maybe I'm wrong.
 
Ranch Hand
Posts: 619
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Derek,

I like the version above better. It's debatable, but I find this version to be simpler.
Hope this helps,
George
[ February 10, 2004: Message edited by: George Marinkovich ]
 
Derek Canaan
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jacques and George,
Just as you do, I like the shorter version too. It's also less clouded. And I like Jacques' reasoning too
Thanks guys,
Derek
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic