Click here to Skip to main content
15,886,919 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: !(How to best use a try catch block) Pin
harold aptroot9-Jul-09 11:01
harold aptroot9-Jul-09 11:01 
GeneralRe: !(How to best use a try catch block) Pin
supercat910-Jul-09 6:09
supercat910-Jul-09 6:09 
GeneralRe: !(How to best use a try catch block) Pin
harold aptroot10-Jul-09 6:24
harold aptroot10-Jul-09 6:24 
GeneralRe: !(How to best use a try catch block) Pin
supercat910-Jul-09 9:36
supercat910-Jul-09 9:36 
GeneralRe: !(How to best use a try catch block) Pin
Thomas Weller10-Jul-09 0:29
Thomas Weller10-Jul-09 0:29 
GeneralRe: !(How to best use a try catch block) Pin
singh.iz.king10-Jul-09 3:43
singh.iz.king10-Jul-09 3:43 
GeneralRe: !(How to best use a try catch block) Pin
supercat910-Jul-09 6:02
supercat910-Jul-09 6:02 
GeneralRe: !(How to best use a try catch block) Pin
Thomas Weller10-Jul-09 18:46
Thomas Weller10-Jul-09 18:46 
supercat9 wrote:
On the other hand, it may not be possible to determine in advance all exceptions that might occur.

Of course not. In that case we wouldn't need exceptions at all...

What I mean is: 'Foreseeable' in terms of business/application logic. If something totally unexpected happens (like e.g. the 'ObjectDisposed' you mentioned), there should be a general top level exception handler at the application level, but for sure such an exception must never be swallowed silently by the executing code. Not in a million years, in no circumstance whatsoever!

supercat9 wrote:
I don't particularly like -1 as a return value

Same with me, but in the case of my example -1 has a clear, discrete meaning that can de documented (less than 4 items -> computation not possible), while in the original snippet -1 means sth. went wrong (and I will never tell you what the problem was...). That's a huge difference - especially on large business-scale software projects, where you might have hundreds of such properties...

Regards
Thomas

www.thomas-weller.de

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Programmer - an organism that turns coffee into software.


GeneralRe: !(How to best use a try catch block) Pin
supercat913-Jul-09 5:19
supercat913-Jul-09 5:19 
GeneralRe: !(How to best use a try catch block) Pin
OriginalGriff13-Jul-09 8:52
mveOriginalGriff13-Jul-09 8:52 
GeneralRe: !(How to best use a try catch block) Pin
supercat914-Jul-09 6:10
supercat914-Jul-09 6:10 
GeneralRe: !(How to best use a try catch block) Pin
BadKarma10-Jul-09 1:25
BadKarma10-Jul-09 1:25 
GeneralRe: !(How to best use a try catch block) Pin
singh.iz.king10-Jul-09 3:50
singh.iz.king10-Jul-09 3:50 
GeneralRe: !(How to best use a try catch block) Pin
Member 448708313-Jul-09 8:17
Member 448708313-Jul-09 8:17 
GeneralRe: !(How to best use a try catch block) Pin
singh.iz.king13-Jul-09 15:20
singh.iz.king13-Jul-09 15:20 
GeneralRe: !(How to best use a try catch block) Pin
mateotrek18-Aug-09 19:19
mateotrek18-Aug-09 19:19 
Generalhow not to check a login [modified] PinPopular
icewolf_snowfire8-Jul-09 6:11
icewolf_snowfire8-Jul-09 6:11 
GeneralRe: how not to check a login Pin
0x3c08-Jul-09 6:46
0x3c08-Jul-09 6:46 
GeneralRe: how not to check a login Pin
icewolf_snowfire8-Jul-09 7:35
icewolf_snowfire8-Jul-09 7:35 
GeneralRe: how not to check a login Pin
Lutosław8-Jul-09 12:39
Lutosław8-Jul-09 12:39 
GeneralRe: how not to check a login Pin
icewolf_snowfire8-Jul-09 15:41
icewolf_snowfire8-Jul-09 15:41 
GeneralRe: how not to check a login Pin
Lutosław9-Jul-09 4:04
Lutosław9-Jul-09 4:04 
GeneralRe: how not to check a login Pin
leppie12-Jul-09 2:15
leppie12-Jul-09 2:15 
GeneralRe: how not to check a login Pin
icewolf_snowfire14-Jul-09 9:32
icewolf_snowfire14-Jul-09 9:32 
GeneralRe: how not to check a login Pin
Lutosław17-Jul-09 10:06
Lutosław17-Jul-09 10:06 

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.