Click here to Skip to main content
15,891,033 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: Strictly Short Circuit Pin
Sander Rossel30-Jan-12 7:54
professionalSander Rossel30-Jan-12 7:54 
JokeRe: Strictly Short Circuit Pin
LetMeFinclOut10-Feb-12 11:37
LetMeFinclOut10-Feb-12 11:37 
GeneralRe: Strictly Short Circuit PinPopular
Shameel30-Jan-12 1:09
professionalShameel30-Jan-12 1:09 
GeneralRe: Strictly Short Circuit Pin
Marbry Hardin30-Jan-12 3:48
Marbry Hardin30-Jan-12 3:48 
GeneralRe: Strictly Short Circuit Pin
Patrick Fox30-Jan-12 6:05
Patrick Fox30-Jan-12 6:05 
GeneralRe: Strictly Short Circuit Pin
sergiogarcianinja30-Jan-12 7:28
sergiogarcianinja30-Jan-12 7:28 
GeneralRe: Strictly Short Circuit Pin
Mohibur Rashid31-Jan-12 19:32
professionalMohibur Rashid31-Jan-12 19:32 
GeneralCode should be 5 or anything above 7 long... PinPopular
Sander Rossel25-Jan-12 21:00
professionalSander Rossel25-Jan-12 21:00 
Before people start... The horror is NOT that this is VB code... Now with that out of the way...
A bit of weird code a colleague found recently...
VB
' This code should always be 5 characters long.
If code.Length < 5 Or code.Length = 6 Or code.Length = 7 Then
   Throw New Exception("Code should be 5 characters long.")
End If
My guess is that the programmer assumed it would be 5 characters long or less. Then it turned out it could be 6 too so the Or code.length = 6 part was added, then the code was 7 at some occurrence... The users weren't stupid enough to enter an 8 character code so that one hasn't been added (yet) Laugh | :laugh:
Why not simply check if code.Length <> 5? Roll eyes | :rolleyes:
It's an OO world.
C#
public class Naerling : Lazy<Person>{
    public void DoWork(){ throw new NotImplementedException(); }
}

GeneralRe: Code should be 5 or anything above 7 long... Pin
Jochen Arndt25-Jan-12 22:24
professionalJochen Arndt25-Jan-12 22:24 
GeneralRe: Code should be 5 or anything above 7 long... Pin
Sander Rossel26-Jan-12 7:26
professionalSander Rossel26-Jan-12 7:26 
GeneralRe: Code should be 5 or anything above 7 long... Pin
ChrisNic27-Jan-12 1:02
ChrisNic27-Jan-12 1:02 
GeneralRe: Code should be 5 or anything above 7 long... Pin
0bx28-Jan-12 4:35
0bx28-Jan-12 4:35 
GeneralRe: Code should be 5 or anything above 7 long... Pin
biagiop198627-Jan-12 2:36
biagiop198627-Jan-12 2:36 
GeneralRe: Code should be 5 or anything above 7 long... Pin
reilly9627-Jan-12 2:40
reilly9627-Jan-12 2:40 
GeneralRe: Code should be 5 or anything above 7 long... Pin
Ameen AboDabash30-Jan-12 20:00
Ameen AboDabash30-Jan-12 20:00 
GeneralRe: Code should be 5 or anything above 7 long... Pin
Gary Huck27-Jan-12 2:42
Gary Huck27-Jan-12 2:42 
GeneralRe: Code should be 5 or anything above 7 long... Pin
CDP180227-Jan-12 2:50
CDP180227-Jan-12 2:50 
GeneralRe: Code should be 5 or anything above 7 long... PinPopular
YvesDaoust27-Jan-12 3:58
YvesDaoust27-Jan-12 3:58 
JokeRe: Code should be 5 or anything above 7 long... Pin
Chris Meech27-Jan-12 6:34
Chris Meech27-Jan-12 6:34 
GeneralRe: Code should be 5 or anything above 7 long... Pin
YvesDaoust27-Jan-12 22:12
YvesDaoust27-Jan-12 22:12 
GeneralRe: Code should be 5 or anything above 7 long... Pin
ZurdoDev27-Jan-12 4:21
professionalZurdoDev27-Jan-12 4:21 
GeneralRe: Code should be 5 or anything above 7 long... Pin
Saksida Bojan27-Jan-12 4:48
Saksida Bojan27-Jan-12 4:48 
GeneralRe: Code should be 5 or anything above 7 long... Pin
XH558v27-Jan-12 6:40
XH558v27-Jan-12 6:40 
GeneralRe: Code should be 5 or anything above 7 long... Pin
bwallan27-Jan-12 9:26
bwallan27-Jan-12 9:26 
GeneralRe: Code should be 5 or anything above 7 long... Pin
Sander Rossel27-Jan-12 9:39
professionalSander Rossel27-Jan-12 9:39 

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.