It's been an active couple of months for O. Z.'s group.
In an effort to combat keying errors and all around bad data, some long overdue validation was added by one of O. Z.'s co-workers to several of the screens, and perhaps most importantly, to the address entry screens.
One area of particular attention, was adding flexibility to the zip code field. You see, the U.S. Post Office uses a 5-digit zip code, plus an optional 4-digit extension. The extension lets them subdivide the zip codes for more efficient handling, and while most folks use the 5-digit version it was decided that the screens should be able to accept and validate either version.
However, being a large, lethargic shop, most code reviews come way after-the-fact and it wasn't until the updated screens were in Production (and working as designed) that O. Z. discovered something curious in a table definition that was modified by this co-worker. Apparently, the co-worker managed to validate the entered zip code, but chose to handle longer variants in a unique way:
Create Table Addresses ( StreetAddress1 varchar2(64) not null, StreetAddress2 varchar2(64), City varchar2(32) not null, State varchar2(2) not null, Zip5 varchar2(5) Comment 'No matter what they enter, one of these will be populated', Zip6 varchar2(6) Comment 'No matter what they enter, one of these will be populated', Zip7 varchar2(7) Comment 'No matter what they enter, one of these will be populated', Zip8 varchar2(8) Comment 'No matter what they enter, one of these will be populated', Zip9 varchar2(9) Comment 'No matter what they enter, one of these will be populated' );
On a hunch, O. Z. dug deeper and found this logic - repeated in the UI, client-side logic behind the UI, the server and stored procedures in the database:
if (zip5 != null) { // … } else if (zip6 != null) { // … } else if (zip7 != null) { // … } else if (zip8 != null) { // … } else if (zip9 != null) { // … }
At this point, O. Z. began to have that feeling, you know the one, deep in the pit of his stomach, so he investigated further, only to find that this co-worker had used this pattern on every field he was assigned to touch. Across screens. Across modules. Across applications. Literally, everywhere.
O. Z.'s co-worker is no more...mercifully, he found some greener pastures to inhabit...but for the time being, his legacy lives on.