Click here to Skip to main content

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, embarrasing 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.

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page  Show 
JokeRe: How do you like your nullsmemberZac Greve10 Dec '12 - 9:18 
CDO. It's like OCD, just in alphabetical order like it should be!

Bob Dole
The internet is a great way to get on the net.

D'Oh! | :doh: 2.0.82.7292 SP6a

GeneralRe: How do you like your nullsmemberFlorin Jurcovici11 Dec '12 - 10:18 
I like my nulls to be null objects.
GeneralCount the horrorsmemberJörgen Andersson6 Dec '12 - 22:37 
 Select Case dataSetNPReport1.Spider.Rows.Count
            Case 0
                xrRichText1.Text = String.Format("Fråga {0}Landsting{0}Riket{0}Frågetext{1}A3{0}{0}{0}{0} -  - {0} - {0}{0} - ", Chr(9), Chr(13))
            Case 1
                xrRichText1.Text = String.Format("Fråga {0}Landsting{0}Riket{0}Frågetext{1}{2}{0}{4}{0}{0}{5}{0}{3}", Chr(9), Chr(13), dataSetNPReport1.Spider.Rows(0).Item(0), Replace(dataSetNPReport1.Spider.Rows(0).Item(2).ToString, "*", ""), dataSetNPReport1.Spider.Rows(0).Item(5), dataSetNPReport1.Spider.Rows(0).Item(6))
            Case 2
                xrRichText1.Text = String.Format("Fråga {0}Landsting{0}Riket{0}Frågetext{1}{2}{0}{4}{0}{0}{5}{0}{3}{1}{6}{0}{8}{0}{0}{9}{0}{7}", Chr(9), Chr(13), dataSetNPReport1.Spider.Rows(0).Item(0), Replace(dataSetNPReport1.Spider.Rows(0).Item(2).ToString, "*", ""), dataSetNPReport1.Spider.Rows(0).Item(5), dataSetNPReport1.Spider.Rows(0).Item(6), dataSetNPReport1.Spider.Rows(1).Item(0), Replace(dataSetNPReport1.Spider.Rows(1).Item(2).ToString, "*", ""), dataSetNPReport1.Spider.Rows(1).Item(5), dataSetNPReport1.Spider.Rows(1).Item(6))
            Case 3
                xrRichText1.Text = String.Format("Fråga {0}Landsting{0}Riket{0}Frågetext{1}{2}{0}{4}{0}{0}{5}{0}{3}{1}{6}{0}{8}{0}{0}{9}{0}{7}{1}{10}{0}{12}{0}{0}{13}{0}{11}", Chr(9), Chr(13), dataSetNPReport1.Spider.Rows(0).Item(0), Replace(dataSetNPReport1.Spider.Rows(0).Item(2).ToString, "*", ""), dataSetNPReport1.Spider.Rows(0).Item(5), dataSetNPReport1.Spider.Rows(0).Item(6), dataSetNPReport1.Spider.Rows(1).Item(0), Replace(dataSetNPReport1.Spider.Rows(1).Item(2).ToString, "*", ""), dataSetNPReport1.Spider.Rows(1).Item(5), dataSetNPReport1.Spider.Rows(1).Item(6), dataSetNPReport1.Spider.Rows(2).Item(0), Replace(dataSetNPReport1.Spider.Rows(2).Item(2).ToString, "*", ""), dataSetNPReport1.Spider.Rows(2).Item(5), dataSetNPReport1.Spider.Rows(2).Item(6))
...
You get the pattern...
People say nothing is impossible, but I do nothing every day.

GeneralRe: Count the horrorsmvpOriginalGriff8 Dec '12 - 4:38 
I think I threw up in my mouth, a little.
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.

GeneralQ: What is the sound of one value coalescing?memberPIEBALDconsult6 Dec '12 - 8:04 
A: It goes BOOM!
 
SQL Server 2008 R2
 
I was just altering some of my code to choose betewen two values via COALESCE. Then I decided I might want to back out the change, but I wanted to leave the existing code in case I wanted to reapply the change later. So I had something like COALESCE ( /* X , */ Y ) Z -- of course, it makes no sense to COALESCE on one value, but I was only going to leave it there momentarily and I don't mind causing errors in order to advance my knowledge of the syntax.
 
The result is Incorrect syntax near ')'. -- I thought that was an odd message.
I checked the documentation: COALESCE ( expression [ ,...n ] ) -- so the syntax should be legal! WTF | :WTF:
But it also goes on to say that COALESCE is equivalent to a CASE and my attempts at
CASE (WHEN Y IS NOT NULL) THEN Y END Z
CASE ELSE Y END Z
have been unsatisfactory. Sigh | :sigh:
General42protectorAspDotNetDev5 Dec '12 - 13:45 
Here's a single line from a horribly formatted SQL view (copied verbatim, minus 58 leading spaces):
WHERE      (MarketingGroupAutoID IN (42))))))) OR
Now that you know the answer (42), we just have to figure out the question. Any theories?

QuestionRe: 42memberZac Greve5 Dec '12 - 14:27 
The answer to life, the universe, and everything else?

Bob Dole
The internet is a great way to get on the net.

D'Oh! | :doh: 2.0.82.7292 SP6a

GeneralRe: 42memberPIEBALDconsult5 Dec '12 - 15:13 
WHERE Head IN (Toilet)
GeneralRe: 42memberAdam R Harris11 Dec '12 - 10:13 
How many roads must a man walk down?
Don't comment your code - it was hard to write, it should be hard to read!

GeneralWould you like to buy an IsNull ?memberPIEBALDconsult5 Dec '12 - 8:04 
(SQL Server 2008 R2.)
 
(CASE WHEN cTT.Total IS NOT NULL THEN cTT.Total ELSE 0 END) as 'Total_Total'
 
A dozen of these in a view... Sigh | :sigh:

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 24 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid