Click here to Skip to main content
15,119,116 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 16:50
mveRick York20-Aug-18 16:50 
GeneralThrowing exception Pin
Mohibur Rashid20-Jul-18 14:39
professionalMohibur Rashid20-Jul-18 14:39 
GeneralRe: Throwing exception Pin
Super Lloyd20-Jul-18 17:45
MemberSuper Lloyd20-Jul-18 17:45 
GeneralRe: Throwing exception Pin
Mohibur Rashid20-Jul-18 20:17
professionalMohibur Rashid20-Jul-18 20:17 
GeneralRe: Throwing exception Pin
Super Lloyd21-Jul-18 1:44
MemberSuper Lloyd21-Jul-18 1:44 
GeneralRe: Throwing exception Pin
Sander Rossel22-Jul-18 4:22
professionalSander Rossel22-Jul-18 4:22 
GeneralRe: Throwing exception Pin
Super Lloyd23-Jul-18 1:07
MemberSuper Lloyd23-Jul-18 1:07 
GeneralRe: Throwing exception Pin
Philippe Mori21-Jul-18 16:30
MemberPhilippe Mori21-Jul-18 16: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 13:41
professionalMohibur Rashid22-Jul-18 13:41 
GeneralRe: Throwing exception Pin
Nathan Minier23-Jul-18 2:49
professionalNathan Minier23-Jul-18 2:49 
GeneralRe: Throwing exception Pin
raddevus24-Jul-18 4:06
mvaraddevus24-Jul-18 4:06 
GeneralBurn Baby, Burn! Pin
Randor 18-Jul-18 15:43
professional Randor 18-Jul-18 15:43 
GeneralRe: Burn Baby, Burn! Pin
Abbas A. Ali19-Jul-18 22:52
professionalAbbas A. Ali19-Jul-18 22:52 
GeneralRe: Burn Baby, Burn! Pin
Bruce Patin20-Jul-18 4:32
MemberBruce Patin20-Jul-18 4:32 
GeneralRe: Burn Baby, Burn! Pin
SeattleC++20-Jul-18 9:01
MemberSeattleC++20-Jul-18 9:01 
GeneralRe: Burn Baby, Burn! Pin
Steve Naidamast20-Jul-18 5:51
professionalSteve Naidamast20-Jul-18 5:51 
GeneralRe: Burn Baby, Burn! Pin
Abbas A. Ali20-Jul-18 7:02
professionalAbbas A. Ali20-Jul-18 7:02 
GeneralRe: Burn Baby, Burn! Pin
Slow Eddie20-Jul-18 15:34
professionalSlow Eddie20-Jul-18 15:34 
GeneralRe: Burn Baby, Burn! Pin
David A. Gray6-Oct-18 11:27
MemberDavid A. Gray6-Oct-18 11:27 
GeneralRe: Burn Baby, Burn! Pin
MSBassSinger20-Jul-18 6:36
professionalMSBassSinger20-Jul-18 6:36 
GeneralRe: Burn Baby, Burn! Pin
Richard Deeming20-Jul-18 6:38
mveRichard Deeming20-Jul-18 6:38 
GeneralRe: Burn Baby, Burn! Pin
MSBassSinger20-Jul-18 7:28
professionalMSBassSinger20-Jul-18 7:28 
GeneralRe: Burn Baby, Burn! Pin
Richard Deeming20-Jul-18 7:52
mveRichard Deeming20-Jul-18 7:52 
GeneralRe: Burn Baby, Burn! Pin
MSBassSinger20-Jul-18 8:01
professionalMSBassSinger20-Jul-18 8:01 
GeneralRe: Burn Baby, Burn! Pin
Robert/Not The Pirate20-Jul-18 9:41
professionalRobert/Not The Pirate20-Jul-18 9: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.