The worst ColdFusion code...ever
Everyone has run across bad code. The world of web development is full of it.
I've seen a lot of ColdFusion code that would make developers cringe, but nothing I've seen rivals the code I found while I was working on a project a while back.
Feast your eyes on this beauty:
<cfset b = 0>
<cfloop query="problemlist">
<cfset b = b + 1>
<cfif b eq 1 or b eq 5 or b eq 9 or b eq 13 or b eq 17 or b eq 21 or b eq 25 or b eq 29 or b eq 33 or b eq 37 or b eq 41 or b eq 45 or b eq 49 or b eq 53 or b eq 57 or b eq 61 or b eq 65 or b eq 69 or b eq 73 or b eq 77 or b eq 81 or b eq 85>
<tr>
<cfelse>
</cfif>
<td><strong>#name#</strong>
<cfif #ListQualify(opencase.tech_diagnosis,",")# contains #id#>
<input type="Checkbox" name="diagnosis_problem#i#" value="#id#" checked>
<cfelse>
<input type="Checkbox" name="diagnosis_problem#i#" value="#id#">
</cfif>
</td>
<cfif b eq 4 or b eq 8 or b eq 12 or b eq 16 or b eq 20 or b eq 24 or b eq 28 or b eq 32 or b eq 36 or b eq 40 or b eq 44 or b eq 48 or b eq 52 or b eq 56 or b eq 60 or b eq 64 or b eq 68 or b eq 72 or b eq 76 or b eq 80 or b eq 84>
</tr>
<cfelse>
</cfif>
</cfloop>
<cfloop query="problemlist">
<cfset b = b + 1>
<cfif b eq 1 or b eq 5 or b eq 9 or b eq 13 or b eq 17 or b eq 21 or b eq 25 or b eq 29 or b eq 33 or b eq 37 or b eq 41 or b eq 45 or b eq 49 or b eq 53 or b eq 57 or b eq 61 or b eq 65 or b eq 69 or b eq 73 or b eq 77 or b eq 81 or b eq 85>
<tr>
<cfelse>
</cfif>
<td><strong>#name#</strong>
<cfif #ListQualify(opencase.tech_diagnosis,",")# contains #id#>
<input type="Checkbox" name="diagnosis_problem#i#" value="#id#" checked>
<cfelse>
<input type="Checkbox" name="diagnosis_problem#i#" value="#id#">
</cfif>
</td>
<cfif b eq 4 or b eq 8 or b eq 12 or b eq 16 or b eq 20 or b eq 24 or b eq 28 or b eq 32 or b eq 36 or b eq 40 or b eq 44 or b eq 48 or b eq 52 or b eq 56 or b eq 60 or b eq 64 or b eq 68 or b eq 72 or b eq 76 or b eq 80 or b eq 84>
</tr>
<cfelse>
</cfif>
</cfloop>
Isn't that beautiful!
Ok, so who has got something better? Anyone?


Pure Crap.
He started by reading the entire file, and searching for certain titles.
He looped through the entire directory doing this. He built a list of XML files that fit his criteria.
Then he re-read the same files, and did a write command to essentially copy them to another directory.
Then he opened each file again, and searched for another parameter in the XML. Stored the file names in a list, and copied them using the same method as before.
He did this four more times. So, he ened up with 6 copies of the file, read EACH sucessful file 6 times.
He was wondering why this particular template took over 30 minutes to run for about 1,000 files.
After cleaning up his code, it ran in under 45 seconds.
<cfif not isDefined("cgi.REMOTE_ADDR")>
<p><strong><span class="error_normal">Cold Fusion is not installed or not running.</span></strong></p>
<cfelse>
<p><span class="fntGreen8"><strong>Cold Fusion is running.</strong></span></p>
<p>Click <strong>next</strong> to continue.<br></p>
</cfif>
I'm taking a wild guess that they never tested the script without cf installed
work out whn next July was.
<cfif condition>
X
<cfelse>
X
</cfif>
if the condition was true, or false, the same code was executed.
Check out http://thedailywtf.com/ for your daily dose of "WTF!s".
No matter how bad it gets I like to check that site to remind me that it *could* be worse!
D
<cfif x eq someValue>
<cfif x eq someValue>
...
</cfif>
</cfif>
an interesting double check... :)
I didn't think anyone was doing CFML anymore
I've got about 380 MB of the crappiest code in the world! I saw a page recently that went something like this:
<cfhttp url="www.thisSite.com/myPage.cfm?myVariable=set"/>
<cfif url.myVariable EQ "set" >
<cfhttp url="www.thisSite.com/myPage.cfm?myVariable=set2&myVariable2=set1"
</cfif>
The original developer was unavailable for comment - why would anyone do this? The rest of the page didn't even use them in ANY way!?!? I tacked it up to unnecessary legacy code.
<cfif b eq 1 or b eq 5 or b eq 9 or b eq 13 or b eq 17 or b eq 21 or b eq 25 or b eq 29 or b eq 33 or b eq 37 or b eq 41 or b eq 45 or b eq 49 or b eq 53 or b eq 57 or b eq 61 or b eq 65 or b eq 69 or b eq 73 or b eq 77 or b eq 81 or b eq 85 or b eq my grandma has gone to lunch :)>
what a beauty !