By using this site, you agree to our Privacy Policy and our Terms of Use. Close
Andir said:
@crash: Exception handling has become more commonplace with programmers lately, and it does get used for program flow. I'm not going to say I haven't thrown exceptions to bail out of deeply nested algorithms because it was easier than creating events for each subclass, but I'd be lying.

No, I am aware (professional programmer myself, that's why I enjoy c++, can't really cheat that way too easily ;) ) but in the context he was refering to thats the purpose of exception handling.

 Let me give you an example.  Say you have a program that opens a file.  You may add an Exception handler (try/catch block) to make sure the file exists and fails gracefully if it doesn't.  You as the programmer DON'T KNOW if the file exists or not, hence the exception handling in case it doesn't.

If you KNEW the file would always exist, then you wouldn't need the try catch block.  If you knew the file will never exist, then there is no point in running the program.  If you know when the file will be there and when it doesn't then you would know when to run the program and when not to, making the exception handling pointless.



I am a Gauntlet Adventurer.

I strive to improve my living conditions by hoarding gold, food, and sometimes keys and potions. I love adventure, fighting, and particularly winning - especially when there's a prize at stake. I occasionally get lost inside buildings and can't find the exit. I need food badly. What Video Game Character Are You?

Mega Man 9 Challenges: 74%

Waltz Tango Jitterbug Bust a move Headbanging
Bunny Hop Mr. Trigger Happy Double Trouble Mr. Perfect Invincible
Almost Invincible No Coffee Break Air Shoes Mega Diet Encore
Peacekeeper Conservationist Farewell To Arms Gamer's Day Daily Dose
Whomp Wiley! Truly Addicted! Truly Hardcore! Conqueror Vanquisher
Destroyer World Warrior Trusty Sidearm Pack Rat Valued Customer
Shop A Holic Last Man Standing Survivor Hard Rock Heavy Metal
Speed Metal Fantastic 9 Fully Unloaded Blue Bomber Eco Fighter
Marathon Fight Quick Draw G Quick Draw C Quick Draw S Quick Draw H
Quick Draw J Quick Draw P Quick Draw T Quick Draw M Quick Draw X