<CFSet ArrayNew = "My Life sucks" >
I inherited a huge intranet at my new job. It is all done using CFWACK (ColdFusion Web Application Construction Kit) procedural style development. No biggie. I have been do that sort of development for years... I learned CF using CFWACK as my guide. But my predecessor loved arrays... As my boss told me "I cannot express to you how much that man loved arrays". It was not some sort of neurosis... this man was psychotic about it. The site is littered with him literally creating and parsing arrays for the sake of doing so. He literally spent four months converting the site from using query datasets to arrays. So there is four months of bat shit crazy code that I have to un-scramble. The man was a human code obfuscater. Oh, and did I mention that the man did not indent his code? I mean, AT ALL? Ever? Never ever?
This is what I wrote my boss the other day:
Sent: Thursday, April 19, 2007 12:10 PM
To: Michael Reynolds
Subject: ArrayNew = My Life sucks
I am really, really, REALLY, REALLY starting to hate arrays. If people made cars the way my predecessor made data structures a go cart would be the size of an oil tanker, have 400 steering wheels, no brakes and starting it would require more secret hand signals than an epileptic third base coach on meth.
Z
Here is an example of the shit I have to deal with:
SELECT * FROM tbl_Contact WHERE NOT Email IS NULL AND StatusID = 2
</cfquery>
<CFSet EmailArray=ArrayNew(2)>
<CFOutput Query="GetContacts">
<CFSet EmailArray[CurrentRow][1]=NAME>
<CFSEt EmailArray[CurrentRow][2]=EMail>
<CFSet EMailArray[CurrentRow][3]=Title>
<CFSet EmailArray[CurrentRow][4]=Addr1>
<CFSet EmailArray[CurrentRow][5]=Addr2>
<CFSet EmailArray[CurrentRow][6]=City>
<CFSet EmailArray[CurrentRow][7]=StateID>
<CFSet EmailArray[CurrentRow][8]=Zip>
<CFSet EmailArray[CurrentRow][9]=ProjID>
<CFQuery NAME="GetProj" Datasource="#DSN#">
SELECT ProjNum, Title FROM tblProj WHERE ID=#ProjID#
</cfquery>
<CFSet EmailArray[CurrentRow][10]=GetProj.ProjNum>
<CFSet EmailArray[CurrentRow][11]=GetProj.Title>
<CFQuery NAME="GetClientName" Datasource="#DSN#">
SELECT tblRP.ClientName FROM tblRP INNER JOIN tblRPProj ON tblRP.ID=tblRPProj.RPID WHERE tblRPProj.ProjID=#ProjID#
</cfquery>
<CFSet EmailArray[CurrentRow][12]=GetClientName.ClientName>
<CFSet EmailArray[CurrentRow][13]=ID>
</cfoutput>
<cfmail Subject="Some email">
<BR>
#DateFormat(Now(),"dddd, mmmm d, yyyy")#<BR>
<BR>
Dear #EMailArray[L][1]#:<BR>
#EmailArray[L][1]#<BR>
#EmailArray[L][3]#<BR>
#EmailArray[L][12]#<BR>
#EmailArray[L][4]#<CFIF Len(TRIM(EmailArray[L][5])) neq 0><BR>
#EmailArray[L][5]#<BR></cfif>
#EmailArray[L][6]#, #Application.StateArray[EmailArray[L][7]][1]# #EMailArray[L][8]#<BR>
<BR>
..... etc
When ever I see ArrayNew I know that my life is going to suck. All I have to say is why in the fark don't you use the variable names? I mean, CF casts the query as a structure with the variable scope being the name of the query for fucks sake. Why in the name of all that is not stupid do you need to turn it into yet another data structure?

There are no comments for this entry.
[Add Comment]