Cleanliness in appearance

September 24, 2007 – 3:06 pm

Cleanliness in appearanceWhen looking for help from others, make things clean when possible.. Here’s what I mean.  I was looking for assistance on an ASP/SQL question and gave the code from my page (which is manipulate for colors when viewing in DreamWeaver or Visual Studio) to a friend, who was viewing the code in plain text. The result was:

If customer_code = “‘JD%'” Then
dcount = “SELECT COUNT(a.Orders) ” & _
“FROM ( ” & _
“SELECT SalesOrderNumber AS Orders ” & _
“FROM MAS90.dbo.SO_04SOHistoryDetail ” & _
“WHERE ItemNumber IN (SELECT item_number FROM johndeere_item_list) ” & _
“UNION ” & _
“SELECT SalesOrderNumber AS Orders ” & _
“FROM MAS90_TTA.dbo.SO_04SOHistoryDetail ” & _
“WHERE ItemNumber IN (SELECT item_number FROM johndeere_item_list) ” & _
“) ” & _
“AS a”
ElseIf customer_code <> “‘JD%'” Then
dcount = “SELECT COUNT(a.Orders) ” & _
“FROM ( ” & _
“SELECT SalesOrderNumber AS Orders ” & _
“FROM MAS90.dbo.SO_04SOHistoryDetail ” & _
“WHERE ItemNumber LIKE ” & customer_code & ” ” & _
“UNION ” & _
“SELECT SalesOrderNumber AS Orders ” & _
“FROM MAS90_TTA.dbo.SO_04SOHistoryDetail ” & _
“WHERE ItemNumber LIKE ” & customer_code & ” ” & _
“) ” & _
“AS a”
End If

Realizing that this was pretty hard to look at, and not knowing if the person would view the page in notepad or a browser window or just copy and paste it into their own Visual Basic editing program, I decided to be of some help since I was seeking their help. Below is the end result:

If customer_code = “‘JD%'” Then
   dcount = SELECT COUNT(a.Orders) ” & _
                FROM ( ” & _
                SELECT SalesOrderNumber AS Orders ” & _
                FROM MAS90.dbo.SO_04SOHistoryDetail ” & _
                WHERE ItemNumber IN (SELECT item_number FROM johndeere_item_list) ” & _
                UNION ” & _
                SELECT SalesOrderNumber AS Orders ” & _
                FROM MAS90_TTA.dbo.SO_04SOHistoryDetail ” & _
                WHERE ItemNumber IN (SELECT item_number FROM johndeere_item_list) ” & _
                ) ” & _
                AS a

 ElseIf customer_code <> “‘JD%'” Then
  dcount = SELECT COUNT(a.Orders) ” & _
                FROM ( ” & _
                SELECT SalesOrderNumber AS Orders ” & _
                FROM MAS90.dbo.SO_04SOHistoryDetail ” & _
                WHERE ItemNumber LIKE ” & customer_code & ” ” & _
                UNION ” & _
                SELECT SalesOrderNumber AS Orders ” & _
                FROM MAS90_TTA.dbo.SO_04SOHistoryDetail ” & _
                WHERE ItemNumber LIKE ” & customer_code & “ ” & _
                ) ” & _
                AS a

End If

As you can see, it could still be made nice, but taking a couple minutes to clean something up really makes a difference.

Post a Comment

%d bloggers like this: