Recent Articles

Aug 2004

Today's Late Post plus a Post that's late

by in Feature Articles on

Don Benson sends in some T-SQL code he came across while hunting a bug:

If @Build = 1 and @Prop = 0
    Begin
        If @NonPropLev >= @BOMLevel
            Begin
                set @NonPropLev = @BOMLevel
                set @NonPParentMode = 1
            End
    End    
If @Build = 1 and @Prop = 0
    Begin
        If @NonPropLev >= @BOMLevel
            Begin
                set @NonPParentMode = 1
                set @NonPropLev = @BOMLevel
            End
End


Hurry, click the Message Box ...

by in Feature Articles on

... otherwise, the visitor to our site will get impatient and just quit waiting for the page to load.

Here's the third part of a submission from  Jake. Combined with part one and part two, I must say, we've got quite an interesting system:


Daphne Du Maurier

by in Feature Articles on

Here's another entertaining find from Marc Holmes. Can you spot the WTF?


You know, there are these things called DataSets ...

by in Feature Articles on

Jake sends in some more code from the beeping server web application. Apparently, the author didn't quite grasp that you can actually SELECT more than one value at a time ...


It doesn't just happen in Basic ...

by in Feature Articles on

Sorry for the late post today ... I've been real swamped and in my final (thank goodness) meeting with a favorite client. In any case, I've see the point made quite often that a lot of the bad programming is done in Basic (VB, VB.Net, etc). You know, implying that us Basic programmers are bad coders ... Well, here's a code snippet from a production system (approved by Mike Strom) that proves a there's at least one more Java programmers not deserving of his/her title ...


Remember when Java didn't have any loop structures?

by in Feature Articles on

Bob Gateaux sends some code from a project he worked on a few years ago. Apparently, this was written before Java implemented loops. This technique does have the distinct advantage, however, of easily inserting “20227“ right there in the middle.

annualMileageChoice = new Choice();
annualMileageChoice.addItem(CHO_PLEASE_ENTER);
annualMileageChoice.addItem("500");
annualMileageChoice.addItem("1000");
annualMileageChoice.addItem("1500");
annualMileageChoice.addItem("2000");
annualMileageChoice.addItem("2500");
annualMileageChoice.addItem("3000");
annualMileageChoice.addItem("3500");
annualMileageChoice.addItem("4000");
annualMileageChoice.addItem("4500");
annualMileageChoice.addItem("5000");
annualMileageChoice.addItem("5500");
annualMileageChoice.addItem("6000");
annualMileageChoice.addItem("6500");
annualMileageChoice.addItem("7000");
annualMileageChoice.addItem("7500");
annualMileageChoice.addItem("8000");
annualMileageChoice.addItem("8500");
annualMileageChoice.addItem("9000");
annualMileageChoice.addItem("9500");
annualMileageChoice.addItem("10000");
annualMileageChoice.addItem("10500");
annualMileageChoice.addItem("11000");
annualMileageChoice.addItem("11500");
annualMileageChoice.addItem("12000");
annualMileageChoice.addItem("12500");
annualMileageChoice.addItem("13000");
annualMileageChoice.addItem("13500");
annualMileageChoice.addItem("14000");
annualMileageChoice.addItem("14500");
annualMileageChoice.addItem("15000");
annualMileageChoice.addItem("15500");
annualMileageChoice.addItem("16000");
annualMileageChoice.addItem("16500");
annualMileageChoice.addItem("17000");
annualMileageChoice.addItem("17500");
annualMileageChoice.addItem("18000");
annualMileageChoice.addItem("18500");
annualMileageChoice.addItem("19000");
annualMileageChoice.addItem("19500");
annualMileageChoice.addItem("20000");
annualMileageChoice.addItem("20500");
annualMileageChoice.addItem("21000");
annualMileageChoice.addItem("21500");
annualMileageChoice.addItem("22000");
annualMileageChoice.addItem("22500");
annualMileageChoice.addItem("23000");
annualMileageChoice.addItem("23500");
annualMileageChoice.addItem("24000");
annualMileageChoice.addItem("24500");
annualMileageChoice.addItem("25000");
annualMileageChoice.addItem("25500");
annualMileageChoice.addItem("26000");
annualMileageChoice.addItem("26500");
annualMileageChoice.addItem("27000");
annualMileageChoice.addItem("27500");
annualMileageChoice.addItem("28000");
annualMileageChoice.addItem("28500");
annualMileageChoice.addItem("29000");
annualMileageChoice.addItem("29500");
annualMileageChoice.addItem("30000");
annualMileageChoice.addItem("30500");
annualMileageChoice.addItem("31000");
annualMileageChoice.addItem("31500");
annualMileageChoice.addItem("32000");
annualMileageChoice.addItem("32500");
annualMileageChoice.addItem("33000");
annualMileageChoice.addItem("33500");
annualMileageChoice.addItem("34000");
annualMileageChoice.addItem("34500");
annualMileageChoice.addItem("35000");
annualMileageChoice.addItem("35500");
annualMileageChoice.addItem("36000");
annualMileageChoice.addItem("36500");
annualMileageChoice.addItem("37000");
annualMileageChoice.addItem("37500");
annualMileageChoice.addItem("38000");
annualMileageChoice.addItem("38500");
annualMileageChoice.addItem("39000");
annualMileageChoice.addItem("39500");
annualMileageChoice.addItem("40000");
annualMileageChoice.addItem("40500");
annualMileageChoice.addItem("41000");
annualMileageChoice.addItem("41500");
annualMileageChoice.addItem("42000");
annualMileageChoice.addItem("42500");
annualMileageChoice.addItem("43000");
annualMileageChoice.addItem("43500");
annualMileageChoice.addItem("44000");
annualMileageChoice.addItem("44500");
annualMileageChoice.addItem("45000");


I swear, it beeps for no reason ... just wait ...

by in Feature Articles on

Here's a snippet from a web project that Jake was lucky enough to inherit ...

Private Sub btnRun_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) 
        Dim QnumAs2 As Int16 = Server.HtmlEncode(Request.Cookies("QnumAs").Value)
        lblError.Visible = False
        If answer1.Text = "" Or answer2.Text = "" Then
            Beep()
            lblError.Text = "ERROR: Answers can NOT be BLANK!!!"
            lblError.Visible = True
            Exit Sub
        End If

        If (QnumAs2 > 2 And answer3.Text = "") Or (QnumAs2 > 3 And answer4.Text = "") Or _
           (QnumAs2 > 4 And answer5.Text = "") Then
            Beep()
            lblError.Text = "ERROR: Answers can NOT be BLANK!!!"
            lblError.Visible = True
            Exit Sub
        End If


Sql.Config

by in Feature Articles on

Rick Olson gives us a peek into a rather interesting system that he developed a while back Here's a snippet from the web.config file. And yes, that is custom parameter handling that you see ...


sp_hi()

by in Feature Articles on

As one of my final projects at work, I'm maintaining an application provided by another vendor. I honestly believe that this is the worst software ever written. From personalized comments (“Mike emailed me, thought we should change this method, so I'm changing it, but I'm not sure why“) to an incredible variety of platforms (VBScript/JScript/C#/VB.Net), this has it all. Including this stored procedure in the main SQL Database:


UnQuote()

by in Feature Articles on

Here's yet another discovery from Tim Cartwright, found of course in a production system:


There has just got to be a better way ...

by in Feature Articles on

Have you ever finished doing something, and then thought to yourself, there has just got to be a better way to do this? Apparently, Mike's colleague has never had one of those moments:


Avoiding the dreaded Refresh

by in Feature Articles on

Frequent readers of this blog are likely familiar with some of the innovative software developed by my current employer. And as you may know, my tenure there is almost over; I have accepted a job offer from another company. However, I think I would be performing a terrible misservice if I didn't share with you some of my favorite products perversions. Of course, don't let that stop you from sending in your own discoveries.

If there was one my company hates, it's blinking. You know, when you click a link or button on a web page, instead of a seamless transition, the page refreshes and causes a ghastly momentary blink while the page reloads. Despite the fact that the entire web operates in this manner, they wanted their web pages to stand apart. No, their webpages would not blink!


When Comments go Wild

by in Feature Articles on

Bil Simser comments on comments ...

I'm always pleased when I see developers commenting code. It means there's something there that should be commented so the next guy will know WTF whoever wrote it was thinking. However much like any FOX special, there are times when "Comments Gone Wild". I present some production code that contains some more, err, useful comments that I've found.


You mean there's a such thing as "toUpperCase()"?

by in Feature Articles on

We get a two-for-one today from Dave, who sends in this Javascript function he found in a product cart implementation page he was lucky enough to inherit ...


YesNo Combos

by in Feature Articles on

Do you remember YesNoReturn()? Me ... I can't seem to clear the burned-in image of that horrendous function from my retina. Thankfully, Tim Cartwright has some more code from the same application that should help ...


When "n * (-1)" Won't do ...

by in Feature Articles on

... just come up with an overly complicated function that achieves the same thing, like this one discovered by mightydog:


How To Query "Pointless Pointless Pointless Pointless Pointless Pointless Pointless"

by in Feature Articles on

Jakeypoo updates us with some more details ...

It's me again.  Alex posted my article earlier today about the worst database structure I've ever seen.  Well, it gets worse.


Pointless Pointless Pointless Pointless Pointless Pointless Pointless

by in Feature Articles on

My coworker Jakeypoo was kind enough to send in this tale ...

I'm sure we all have our stories of nightmarish projects inherited from clients, whether the secretary's cousin programmed a critical application in JavaScript or a community outreach program let a group home design their customer tracking application.  Imagine my surprise when we got one that had beautifully written, well-commented ASP pages.  I thought this would be easy.


GetUserPrivileges()

by in Feature Articles on

Tim Cartwright astonishes us yet again ...

A while ago I had a need to add some additional security to the application that I had inherited. This was for a second application that would be using the same database as the legacy application. Since it already had custom role based security in place I figured how hard could this be? So I went in search of where to add my new roles. I found the answer in the users table in a field that was a comma delimited list of roles per user. Ex:

UserId UserName Roles
1 Tim USER,SUPERVISOR,MANAGER
2 Mary USER
3 Joe USER,SUPERVISOR

Whatever you do, don't click that button ...

by in Feature Articles on

... because if you do, the DoNothing subroutine will fire! And don't even think about closing this web page (from Phil Harvey) ... it could cancel your fax transmission!


Good Table Names, Redux

by in Feature Articles on

On Tuesday, we saw an ... erm ... interesting example of database table names. Now, prepare yourself for a peek into the database that John Carter has the pleasure to work with. Perhaps the DBA wanted to ensure compatibility with RDMS which only support table names no greater than 3 chars?


YesNoReturn

by in Feature Articles on

I sat here for a few minutes trying to think of some insight or commentary to add to this code that Tim Cartwright sent in. Maybe I'm still in awe, but I don't think there is anything I could possibly say to augment this ...


Writing Bugfree software

by in Feature Articles on

Craig sends us some more code from the same company that gave us Endless Datagrids.Aparantly, this “failsafe“ method of programming comes direct from a presidential mandate. My only question is ... where do I buy this bugfree software?


FreeThisSchnizzle()

by in Feature Articles on
Levi Broderick sent in an entertaining story a while ago that has been patiently waiting to be shared. And what better than the 1AM post to accomplish this? 

In the Spring of 2003, I was attending Carnegie Mellon and enrolled in an introductory C class.  One of our homework assignments was to implement a linked list.  Such an implementation had to include a function that took as an argument a pointer to the head node, freed all the memory associated with the linked list, and returned nothing.

Anyway, when we had done this assignment and turned it in, our TA sent us a message that included a code snippet:


Good Table Names

by in Feature Articles on

Tim Heuer seems to have some pretty bad luck when it comes to inheriting database systems. Believe it or not, today's screen shot comes from the Tables view in SQL Server Enterprise manager and is not a list of files. Thankfully, the DBA used common-sense, easy to understand column names for these tables, such as [c:0x:x:Line1] for the summary field. 


objDocument.SetDocumentIndex = "WTF"

by in Feature Articles on

It seems that I have a few more submissions that days in the week, so I'll try to post in the evening (or early AM, as it may be) when I can. But of course, don't let that discourage you from sending in your WTF moments.

In any case, continuing on the theme of property (mis)use, Aiax shows us how a colleague doesn't quite grasp what properties are all about ...


Properties?

by in Feature Articles on

David Crowell's colleague found an absolutely wonderful way to avoid using properties. Who needs em, anyways?