3 ms·
tl;dr: the most important code I ever wrote saved us millions of dollars by setting `disabled="disabled"` on an html element I don't know if this is the correc
by eqdw 8y ago
tl;dr: the most important code I ever wrote saved us millions of dollars by setting `disabled="disabled"` on an html element
I don't know if this is the correct measure for "most important" but it is provably and measurably the most valuable (in terms of dollars) code that I have ever written.
I used to work at a fintech company. This company gave out loans. One of the main reasons you might get a loan at this company instead of a bank is because the bank refused to give you a loan. So, as you might imagine, this company needed to deal with a considerable default risk, and be very, very careful in its underwriting.
At one point, we had a minor crisis. The default rate was considerably higher than we had projected, and this was threatening the business. Without getting into details: this was potentially an existential risk to our business.
Preliminary analysis of the problem revealed a few significant causes. One: our underwriting rules were complicated, and manually applied. At the time we were working on a rules engine that would offload a lot of fiddly rule checks, but this was still a few months out. In the interim, people would manually check the spreadsheet and they made mistakes.
I was tasked with fixing this with a stopgap. So what I did was I added about 15 lines of code to our front-end. It collected a handful of stats (that were already being exposed to the front-end) that covered ~80% of the underwriting cases, and hard-coded the current underwriting rules on them. If the stats on a given loan didn't meet the threshold, and would therefore be rejected by our manual underwriters, my code disabled the 'approve' button.
The entire code was a function that looked something like
```javascript
THRESHOLD_1 = 123;
THRESHOLD_2 = 123;
... //etc
function buttonDisabled(){
if( stat1 < THRESHOLD_1 ||
stat2 < THRESHOLD_2 ||
... //etc) {
return true;
} else {
false;
}
}
```
plus the react binding necessary to attach this to the approve button.
I got this done start to finish in about two days (most of those days spend talking to PMs trying to figure out what the values of the THRESHOLD constants should be), and it was deployed in prod by the end of day 4. It was cheap, terrible, shitty code, but that was ok! Because it was throwaway code. We had an existing project to replace this with an actual rules engine, and it was on track to get rolled out two months later. So who cares about shitty code, it's getting replaced in two months. In the interim, speed was more important, and they got speed.
By my own numbers (based on estimates as I didn't have access to real numbers), I estimate that this code saved somewhere between $500k and $2M in defaults. Whatever it was, the company agreed. Every Friday afternoon the CEO would hand out recognition awards for someone who went above and beyond, and for this code I won the award three weeks in a row.
tl;dr: the most important code I ever wrote saved us millions of dollars by setting `disabled="disabled"` on an html element