Click here to Skip to main content
13,042,166 members (77,527 online)

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: Something is not as I expected Pin
Mohibur Rashid20-Jun-13 22:25
professionalMohibur Rashid20-Jun-13 22:25 
GeneralRe: Something is not as I expected Pin
Amitosh Swain20-Jun-13 22:32
memberAmitosh Swain20-Jun-13 22:32 
GeneralRe: Something is not as I expected Pin
Rob Grainger23-Jun-13 23:57
memberRob Grainger23-Jun-13 23:57 
GeneralRe: Something is not as I expected Pin
Member 467320212-Jul-13 13:11
memberMember 467320212-Jul-13 13:11 
GeneralEverywhere a single Catch block used catching top Exception all times. Pin
Mohammed Hameed19-Jun-13 20:28
professionalMohammed Hameed19-Jun-13 20:28 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. Pin
cjb11019-Jun-13 21:13
membercjb11019-Jun-13 21:13 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. Pin
Mohammed Hameed19-Jun-13 21:20
professionalMohammed Hameed19-Jun-13 21:20 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. Pin
Rob Grainger24-Jun-13 0:02
memberRob Grainger24-Jun-13 0:02 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. Pin
Jarek Kruza19-Jun-13 21:56
memberJarek Kruza19-Jun-13 21:56 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. Pin
Mohammed Hameed19-Jun-13 22:08
professionalMohammed Hameed19-Jun-13 22:08 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. Pin
Jarek Kruza20-Jun-13 1:30
memberJarek Kruza20-Jun-13 1:30 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. Pin
Rob Grainger24-Jun-13 0:04
memberRob Grainger24-Jun-13 0:04 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. Pin
Mohammed Hameed24-Jun-13 0:31
professionalMohammed Hameed24-Jun-13 0:31 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. Pin
Chris Ross 224-Jun-13 2:32
memberChris Ross 224-Jun-13 2:32 
I concur. Further, once the exception has been handled there should (normally) be no need to rethrow it.

This rule leads to the useful guidline: catch exceptions at the lowest level where they can be meaningfully (i.e. completely) handled.

The exception to the no-need-to-rethrow rule is when some cleanup action is needed as the stack is unwound. In that case, catch the specific type of exception, do the local cleanup only, and rethrow (ideally, using throw without a paramter - to preserve the stack trace). Do not duplicate the work that will be done in the can-meaningfully-handle-it catch block (such as logging, notifying the user, clearing context).

Note that the using (...){...} construct implicitly follows this rule: in the event that the contained block of code throws an exception, it will automatically invoke the Dispose() method on the item allocated by the using() statement.
GeneralRe: Everywhere a single Catch block used catching top Exception all times. Pin
Rob Grainger24-Jun-13 4:08
memberRob Grainger24-Jun-13 4:08 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. Pin
V.19-Jun-13 23:25
professionalV.19-Jun-13 23:25 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. Pin
Mohammed Hameed19-Jun-13 23:56
professionalMohammed Hameed19-Jun-13 23:56 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. Pin
cjb11020-Jun-13 0:12
membercjb11020-Jun-13 0:12 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. Pin
Mohammed Hameed20-Jun-13 0:26
professionalMohammed Hameed20-Jun-13 0:26 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. Pin
V.20-Jun-13 0:31
professionalV.20-Jun-13 0:31 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. Pin
Mohammed Hameed20-Jun-13 1:11
professionalMohammed Hameed20-Jun-13 1:11 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. Pin
Richard Deeming20-Jun-13 1:36
professionalRichard Deeming20-Jun-13 1:36 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. Pin
V.20-Jun-13 1:39
professionalV.20-Jun-13 1:39 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. Pin
AnalogNerd24-Jun-13 2:26
memberAnalogNerd24-Jun-13 2:26 
GeneralRe: Everywhere a single Catch block used catching top Exception all times. Pin
Mohammed Hameed24-Jun-13 2:37
professionalMohammed Hameed24-Jun-13 2:37 
GeneralRelational database reinvented as a flat file... Pin
johnsyd19-Jun-13 19:58
memberjohnsyd19-Jun-13 19:58 
GeneralRe: Relational database reinvented as a flat file... Pin
AlexCode19-Jun-13 20:25
professionalAlexCode19-Jun-13 20:25 
GeneralRe: Relational database reinvented as a flat file... Pin
johnsyd19-Jun-13 21:22
memberjohnsyd19-Jun-13 21:22 
GeneralRe: Relational database reinvented as a flat file... Pin
NormDroid19-Jun-13 20:43
professionalNormDroid19-Jun-13 20:43 
GeneralRe: Relational database reinvented as a flat file... Pin
AlexCode19-Jun-13 21:26
professionalAlexCode19-Jun-13 21:26 
GeneralRe: Relational database reinvented as a flat file... Pin
Richard Deeming20-Jun-13 1:32
professionalRichard Deeming20-Jun-13 1:32 
GeneralRe: Relational database reinvented as a flat file... Pin
jim lahey20-Jun-13 1:57
memberjim lahey20-Jun-13 1:57 
GeneralWhy stick to just one database? Pin
johnsyd19-Jun-13 17:52
memberjohnsyd19-Jun-13 17:52 
GeneralRe: Why stick to just one database? Pin
krumia19-Jun-13 17:55
memberkrumia19-Jun-13 17:55 
GeneralRe: Why stick to just one database? Pin
johnsyd19-Jun-13 18:07
memberjohnsyd19-Jun-13 18:07 
GeneralRe: Why stick to just one database? Pin
PIEBALDconsult19-Jun-13 18:37
professionalPIEBALDconsult19-Jun-13 18:37 
GeneralRe: Why stick to just one database? Pin
vonb19-Jun-13 19:25
professionalvonb19-Jun-13 19:25 
GeneralRe: Why stick to just one database? Pin
AlexCode19-Jun-13 20:23
professionalAlexCode19-Jun-13 20:23 
GeneralRe: Why stick to just one database? Pin
Adriaan Davel19-Jun-13 21:55
memberAdriaan Davel19-Jun-13 21:55 
AnswerRe: Why stick to just one database? Pin
GastonV19-Jun-13 20:28
memberGastonV19-Jun-13 20:28 
GeneralRe: Why stick to just one database? Pin
cjb11019-Jun-13 21:15
membercjb11019-Jun-13 21:15 
GeneralRe: Why stick to just one database? Pin
johnsyd25-Jun-13 15:01
memberjohnsyd25-Jun-13 15:01 
GeneralRe: Why stick to just one database? Pin
Adriaan Davel19-Jun-13 21:59
memberAdriaan Davel19-Jun-13 21:59 
GeneralRe: Why stick to just one database? Pin
Richard Deeming20-Jun-13 1:30
professionalRichard Deeming20-Jun-13 1:30 
GeneralRe: Why stick to just one database? Pin
jim lahey20-Jun-13 2:04
memberjim lahey20-Jun-13 2:04 
GeneralRe: Why stick to just one database? Pin
NeverJustHere20-Jun-13 19:29
memberNeverJustHere20-Jun-13 19:29 
GeneralRe: Why stick to just one database? Pin
johnsyd25-Jun-13 15:15
memberjohnsyd25-Jun-13 15:15 
GeneralRe: Why stick to just one database? Pin
johnsyd25-Jun-13 15:10
memberjohnsyd25-Jun-13 15:10 
GeneralHow To Use Session Variables Pin
AnalogNerd18-Jun-13 3:43
memberAnalogNerd18-Jun-13 3:43 
GeneralRe: How To Use Session Variables Pin
OriginalGriff18-Jun-13 5:04
protectorOriginalGriff18-Jun-13 5:04 

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.


Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 20 Jul 2017
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid