• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Derek Canaan
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,
Need your opinion on this:
Which is more preferred and why?
thanks,
derek
 
Jacques Bosch
Ranch Hand
Posts: 319
  • Mark post as helpful
  • send pies
  • 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.
 
George Marinkovich
Ranch Hand
Posts: 619
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic