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:
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
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^')>
I actually have 1500 lines remaining in this thing.....
killme
now






Loading....