0

Legacy Code Part II - Is code supposed to make you laugh?

ColdFusion

OK, I really don't mean to obsess on this, but since I have had to work with it for multiple days, I have earned the right... believe me! I am not sure I have *ever* seen a better example of what not to do. It is truly just bizarre. Here is the scenario:

In this app, a Loan Application can have multiple Borrowers. Each Borrower can have multiple Dependents. Now, you are probably thinking that there would be at least 3 tables involved in that equation. Think again. Each Borrower record, there is a field "borrow_dependent_ages", a varchar field, that is supposed to be a comma seperated list of ages of Dependents. This is the only handle on how many Dependents each Borrower has.

OK, that is bad enough right? We haven't even come close to the comedy gold yet. So in this file that gets generated and sent to underwriting, we create a new line for each Dependent that looks like this after decryption:

03B[SSN of Borrower][age of this dependent]

So, how would we achieve this? Obviously we would loop through Borrowers, then loop through the comma seperated list of Dependent ages, right?

How about this approach?












 

		





  





	







	

	

	

		

	

		

			

			

			

				

				

				

  					

				@+*x^')>

				 

				

			

		

	

	







	

	

	

		

		

		

  			

		@+*x^')>

		 

		

		









	

	

	

  		

	@+*x^')>

	 

	

	



















 

		





  





	







	

	

	

		

	

		

			

			

			

				

				

				

  					

				@+*x^')>

				 

				

			

		

	

	







	

	

	

		

		

		

  			

		@+*x^')>

		 

		

		









	

	

	

  		

	@+*x^')>

	 

	

	


Not only did the developer think his solution was good enough to write, he thought is was so good he should write it twice, once for each Borrower! Seriously, take a moment to copy/paste that code into an editor and walk through following the logic. WARNING: I will not replace any monitors that have coffee spit all over them from laughter.

So, here is the replacement code:




	
	
	
			
			
			
			
		
	




EDIT: I just came back to my desk and found this compliments of Aaron

I actually have 1500 lines remaining in this thing.....

kill
me
now

tags:
ColdFusion
todd sharp said:
 
That picture is classic. That should be my wallpaper.

Hey, at least it looks like they had good indentation in their code...can you imagine if they didn't?
 
posted 1058 days ago
Add Comment Reply to: this comment OR this thread
 
Scott Stroz said:
 
I asked you to make the bad man stop.


BTW - in my browser, the main content area is all the way to the right. I thought at one time it was centered. Anyone else seeing this?
 
posted 1058 days ago
Add Comment Reply to: this comment OR this thread
 
 
That is how Dave's layout has been for quite awhile. The Spot layouts are centered by default though.
 
posted 1058 days ago
Add Comment Reply to: this comment OR this thread
 
 
lol... it is "float:right" Scott. In the former green theme I had the content centered. We have the ability to modify CSS on the Spots and I decided to do something different with this one. I am sure I will get bored with it in a week or two, and submit it to http://www.isdx.net and try something new. :)
 
posted 1058 days ago
Add Comment Reply to: this comment OR this thread
 
John Allen said:
 
Ohhh man, oooohhhhhhhh ohhhhhhhh, ouch, give me chest pains.
 
posted 1058 days ago
Add Comment Reply to: this comment OR this thread
 
Lola LB said:
 
Perhaps the original developer was thinking "measure twice, cut once"?
 
posted 1058 days ago
Add Comment Reply to: this comment OR this thread
 
 
Lola, you lost me at "Perhaps the original developer was thinking" :D
 
posted 1058 days ago
Add Comment Reply to: this comment OR this thread
 
 
Yeah, he was probably thinking something along the lines of

"If only there was some easy method to traverse this very complex string broken up by commas."

followed shortly by:

"Wow, I really really really suck at programming."
 
posted 1058 days ago
Add Comment Reply to: this comment OR this thread
 
todd sharp said:
 
John - your picture just scares the shit out of me.
 
posted 1058 days ago
Add Comment Reply to: this comment OR this thread
 
Kevin Sargent said:
 
"followed shortly by:

"Wow, I really really really suck at programming.""

HA!

I'm the first to admit I've got a lot to learn after 5 or 6 years of CF'ing. I've looked back at my old code and laughed, but seriously - NOT LIKE THAT! wow! sorry for anyone that has to deal with that.
 
posted 1056 days ago
Add Comment Reply to: this comment OR this thread
 

Search