Click here to Skip to main content
15,881,898 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Nature tester Pin
Rick York20-Aug-18 15:50
mveRick York20-Aug-18 15:50 
GeneralThrowing exception Pin
Mohibur Rashid20-Jul-18 13:39
professionalMohibur Rashid20-Jul-18 13:39 
GeneralRe: Throwing exception Pin
Super Lloyd20-Jul-18 16:45
Super Lloyd20-Jul-18 16:45 
GeneralRe: Throwing exception Pin
Mohibur Rashid20-Jul-18 19:17
professionalMohibur Rashid20-Jul-18 19:17 
GeneralRe: Throwing exception Pin
Super Lloyd21-Jul-18 0:44
Super Lloyd21-Jul-18 0:44 
GeneralRe: Throwing exception Pin
Sander Rossel22-Jul-18 3:22
professionalSander Rossel22-Jul-18 3:22 
GeneralRe: Throwing exception Pin
Super Lloyd23-Jul-18 0:07
Super Lloyd23-Jul-18 0:07 
GeneralRe: Throwing exception Pin
Philippe Mori21-Jul-18 15:30
Philippe Mori21-Jul-18 15:30 
Well, at first it seems that a simple if statement would do… However, if the condition should not occurs, it might be easier to find the problem during debugging if the debugger stop on exception or write something to the output log.

But let assume that some other code might also throw an Exception and if that case, you want to execute the code in catch clause too, then it might be acceptable after all if that code should not be executed if no exception are thrown.

As shown in the above example, all code can be removed as nothing else is done. In real code, it would not be the case! And the cleanest code to write directly depends on what missing code do and if some other code could throw or not.
Philippe Mori

GeneralRe: Throwing exception Pin
Mohibur Rashid22-Jul-18 12:41
professionalMohibur Rashid22-Jul-18 12:41 
GeneralRe: Throwing exception Pin
Nathan Minier23-Jul-18 1:49
professionalNathan Minier23-Jul-18 1:49 
GeneralRe: Throwing exception Pin
raddevus24-Jul-18 3:06
mvaraddevus24-Jul-18 3:06 
GeneralBurn Baby, Burn! PinPopular
Randor 18-Jul-18 14:43
professional Randor 18-Jul-18 14:43 
GeneralRe: Burn Baby, Burn! PinPopular
Abbas A. Ali19-Jul-18 21:52
professionalAbbas A. Ali19-Jul-18 21:52 
GeneralRe: Burn Baby, Burn! Pin
Bruce Patin20-Jul-18 3:32
Bruce Patin20-Jul-18 3:32 
GeneralRe: Burn Baby, Burn! Pin
SeattleC++20-Jul-18 8:01
SeattleC++20-Jul-18 8:01 
GeneralRe: Burn Baby, Burn! Pin
Steve Naidamast20-Jul-18 4:51
professionalSteve Naidamast20-Jul-18 4:51 
GeneralRe: Burn Baby, Burn! Pin
Abbas A. Ali20-Jul-18 6:02
professionalAbbas A. Ali20-Jul-18 6:02 
GeneralRe: Burn Baby, Burn! Pin
Slow Eddie20-Jul-18 14:34
professionalSlow Eddie20-Jul-18 14:34 
GeneralRe: Burn Baby, Burn! Pin
David A. Gray6-Oct-18 10:27
David A. Gray6-Oct-18 10:27 
GeneralRe: Burn Baby, Burn! Pin
MSBassSinger20-Jul-18 5:36
professionalMSBassSinger20-Jul-18 5:36 
GeneralRe: Burn Baby, Burn! Pin
Richard Deeming20-Jul-18 5:38
mveRichard Deeming20-Jul-18 5:38 
GeneralRe: Burn Baby, Burn! Pin
MSBassSinger20-Jul-18 6:28
professionalMSBassSinger20-Jul-18 6:28 
GeneralRe: Burn Baby, Burn! Pin
Richard Deeming20-Jul-18 6:52
mveRichard Deeming20-Jul-18 6:52 
GeneralRe: Burn Baby, Burn! Pin
MSBassSinger20-Jul-18 7:01
professionalMSBassSinger20-Jul-18 7:01 
GeneralRe: Burn Baby, Burn! Pin
Robert/Not The Pirate20-Jul-18 8:41
professionalRobert/Not The Pirate20-Jul-18 8:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.