Click here to Skip to main content
15,922,015 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: It's a jungle in there Pin
Fabio Franco10-Aug-11 9:25
professionalFabio Franco10-Aug-11 9:25 
GeneralRe: It's a jungle in there Pin
Sander Rossel10-Aug-11 11:14
professionalSander Rossel10-Aug-11 11:14 
GeneralRe: It's a jungle in there Pin
Fabio Franco11-Aug-11 5:01
professionalFabio Franco11-Aug-11 5:01 
GeneralRe: It's a jungle in there Pin
Sander Rossel11-Aug-11 11:59
professionalSander Rossel11-Aug-11 11:59 
GeneralRe: It's a jungle in there Pin
cpkilekofp16-Aug-11 13:02
cpkilekofp16-Aug-11 13:02 
GeneralRe: It's a jungle in there Pin
Fabio Franco17-Aug-11 1:36
professionalFabio Franco17-Aug-11 1:36 
GeneralRe: It's a jungle in there Pin
GibbleCH10-Aug-11 3:48
GibbleCH10-Aug-11 3:48 
GeneralRe: It's a jungle in there Pin
Sander Rossel10-Aug-11 7:57
professionalSander Rossel10-Aug-11 7:57 
Or my favourite:
VB
Try
   ' (Lots of) code here.
Catch ex As Exception
   LogError(0, ex.Message, "SomeClass.SomeMethod")
End Try

Yes, we did not pass the Exception Object to the LogError Method, we provided some parameters as Strings. I still don't know what the first parameter is. It is always 0... "SomeClass.SomeMethod" is not fetched from the Exception Object, but passed as a fixed String. It gets worse, because this piece of code is copied in EVERY Try Catch block (except the empty ones of course). See how copying "SomeClass.SomeMethod" does not work for "SomeClass.OtherMethod"? Smile | :)
So our logging is often not very reliable. And even if it is (it is not ALL bad) it usually does not say very much because we don't log stacktraces etc. A log that says "Reference not set to an instance of an Object" in a Method with some 100 lines of code is really not very helpful Smile | :)
Next to that there is a Try Catch block in almost EVERY Method, but NEVER a ReThrow or a MessageBox.Show to the user. What a way to handle Exceptions! Thumbs Up | :thumbsup:

It annoyed me so much I decided to write an article about it Smile | :)
It's an OO world.

GeneralRe: It's a jungle in there Pin
Bernhard Hiller9-Aug-11 20:32
Bernhard Hiller9-Aug-11 20:32 
GeneralRe: It's a jungle in there Pin
BobJanova10-Aug-11 1:36
BobJanova10-Aug-11 1:36 
GeneralRe: It's a jungle in there Pin
Amar Chaudhary10-Aug-11 2:50
Amar Chaudhary10-Aug-11 2:50 
GeneralRe: It's a jungle in there Pin
Member 776995910-Aug-11 8:36
Member 776995910-Aug-11 8:36 
GeneralRe: It's a jungle in there Pin
Br.Bill10-Aug-11 6:58
Br.Bill10-Aug-11 6:58 
GeneralRe: It's a jungle in there [modified] Pin
RobCroll14-Aug-11 3:29
RobCroll14-Aug-11 3:29 
GeneralRe: It's a jungle in there Pin
GibbleCH15-Aug-11 5:31
GibbleCH15-Aug-11 5:31 
GeneralRe: It's a jungle in there Pin
richard_k15-Aug-11 21:34
richard_k15-Aug-11 21:34 
GeneralMessage Removed Pin
8-Aug-11 4:13
professionalN_tro_P8-Aug-11 4:13 
GeneralRe: Validation fails so lets not use it Pin
fjdiewornncalwe9-Aug-11 3:28
professionalfjdiewornncalwe9-Aug-11 3:28 
GeneralRe: Validation fails so lets not use it Pin
thoiness1-Sep-11 4:55
thoiness1-Sep-11 4:55 
GeneralRe: Validation fails so lets not use it Pin
Shameel9-Aug-11 4:38
professionalShameel9-Aug-11 4:38 
GeneralRe: Validation fails so lets not use it Pin
Chris Berger9-Aug-11 6:18
Chris Berger9-Aug-11 6:18 
GeneralRe: Validation fails so lets not use it Pin
Lutosław11-Aug-11 23:18
Lutosław11-Aug-11 23:18 
GeneralIf not null, return value else return null Pin
Keith Barrow7-Aug-11 1:58
professionalKeith Barrow7-Aug-11 1:58 
GeneralRe: If not null, return value else return null Pin
BillW338-Aug-11 13:32
professionalBillW338-Aug-11 13:32 
GeneralRe: If not null, return value else return null Pin
RobCroll9-Aug-11 0:48
RobCroll9-Aug-11 0:48 

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.