One of the fundamental axioms of software development — #9 on the list, actually — is that "there is always a better way." This holds that there is no such thing as Perfect Code, only Good Code which is appropriately correct, appropriately optimized, and appropriately documented for the situation at hand. On the other hand, a lesser-known axioms (#1873, for those keeping count) is that "there is always a worse way." No matter how bad a particular block of code may seem... someone, somewhere, somehow will develop something even worse.

Of course, this being The Daily WTF, I figured that we'd be above that latter axiom. With all of the bad code published here (don't forget: submit your own!), surely we've seen the worst possible way of doing something. The Absolute Zero of bad code, if you will. I mean, once you've seen one declare-a-boolean-variable-for-every-state-and-have-if-statements-determine-the-selected-state-and-print-it-out (like this), you've seen them all, right?

Not so much. It took nearly five years to happen, but Georg Zimmer sent in an even worse state selector. "I was tasked with fixing a simple bug," he explained, "for some reason, Arkansas customers kept accidently changing their state to Arizona, and obviously this created some mailing problems. It didn't take very long to realize the problem."

if ($province == "AL - Alabama") {
    $provinces = "
    	<select name='usr_province'>
    	<option selected='selected'>AL - Alabama</option>
    	<option>AK - Alaska</option>
    	<option>AZ - Arizona</option>
    	<option>AR - Arkansas</option>
    	<option>AA - Armed Forces America</option>
    	<option>AE - Armed Forces Other Areas</option>
    	<option>AP - Armed Forces Pacific</option>
    	<option>CA - California</option>
    	<option>CO - Colorado</option>
    	<option>CT - Connecticut</option>
    	<option>DE - Delaware</option>
    	<option>DC - District of Columbia</option>
    	<option>FL - Florida</option>
    	<option>GA - Georgia</option>
    	<option>GU - Guam</option>
    	<option>HI - Hawaii</option>
    	<option>ID - Idaho</option>
    	<option>IL - Illinois</option>
    	<option>IN - Indiana</option>
    	<option>IA - Iowa</option>
    	<option>KS - Kansas</option>
    	<option>KY - Kentucky</option>
    	<option>LA - Louisiana/option>
    	<option>ME - Maine</option>
    	<option>MD - Maryland</option>
    	<option>MA - Massachusetts</option>
    	<option>MI - Michigan</option>
    	<option>MN - Minnesota</option>
    	<option>MS - Mississippi</option>
    	<option>MO - Missouri</option>
    	<option>MT - Montana</option>
    	<option>NE - Nebraska</option>
    	<option>NV - Nevada</option>
    	<option>NH - New Hampshire</option>
    	<option>NJ - New Jersey</option>
    	<option>NM - New Mexico</option>
    	<option>NY - New York</option>
    	<option>NC - North Carolina</option>
    	<option>OH - Ohio</option>
    	<option>OK - Oklahoma</option>
    	<option>OR - Oregon</option>
    	<option>PA - Pennsylvania</option>
    	<option>PR - Puerto Rico</option>
    	<option>RI - Rhode Island</option>
    	<option>SC - South Carolina</option>
    	<option>SD - South Dakota</option>
    	<option>TN - Tennessee</option>
    	<option>TX - Texas</option>
    	<option>VI - U.S. Virgin Islands</option>
    	<option>UT - Utah</option>
    	<option>VT - Vermont</option>
    	<option>VA - Virginia</option>
    	<option>WA - Washington</option>
    	<option>WV - West Virginia</option>
    	<option>WI - Wisconsin</option>
    	<option>WY - Wyoming</option>        
    	</select>";
} else if ($province == "AK - Alaska") {
    $provinces = "
    	<select name='usr_province'>
    	<option>AL - Alabama</option>
    	<option selected='selected'>AK - Alaska</option>
    	<option>AZ - Arizona</option>
    	<option>AR - Arkansas</option>
    	<option>AA - Armed Forces America</option>
    	<option>AE - Armed Forces Other Areas</option>
    	<option>AP - Armed Forces Pacific</option>
    	<option>CA - California</option>
    	<option>CO - Colorado</option>
    	<option>CT - Connecticut</option>
    	<option>DE - Delaware</option>
    	<option>DC - District of Columbia</option>
    	<option>FL - Florida</option>
    	<option>GA - Georgia</option>
    	<option>GU - Guam</option>
    	<option>HI - Hawaii</option>
    	<option>ID - Idaho</option>
    	<option>IL - Illinois</option>
    	<option>IN - Indiana</option>
    	<option>IA - Iowa</option>
    	<option>KS - Kansas</option>
    	<option>KY - Kentucky</option>
    	<option>LA - Louisiana/option>
    	<option>ME - Maine</option>
    	<option>MD - Maryland</option>
    	<option>MA - Massachusetts</option>
    	<option>MI - Michigan</option>
    	<option>MN - Minnesota</option>
    	<option>MS - Mississippi</option>
    	<option>MO - Missouri</option>
    	<option>MT - Montana</option>
    	<option>NE - Nebraska</option>
    	<option>NV - Nevada</option>
    	<option>NH - New Hampshire</option>
    	<option>NJ - New Jersey</option>
    	<option>NM - New Mexico</option>
    	<option>NY - New York</option>
    	<option>NC - North Carolina</option>
    	<option>OH - Ohio</option>
    	<option>OK - Oklahoma</option>
    	<option>OR - Oregon</option>
    	<option>PA - Pennsylvania</option>
    	<option>PR - Puerto Rico</option>
    	<option>RI - Rhode Island</option>
    	<option>SC - South Carolina</option>
    	<option>SD - South Dakota</option>
    	<option>TN - Tennessee</option>
    	<option>TX - Texas</option>
    	<option>VI - U.S. Virgin Islands</option>
    	<option>UT - Utah</option>
    	<option>VT - Vermont</option>
    	<option>VA - Virginia</option>
    	<option>WA - Washington</option>
    	<option>WV - West Virginia</option>
    	<option>WI - Wisconsin</option>
    	<option>WY - Wyoming</option>        
    	</select>";
} else if ($province == "AZ - Arizona") {
    $provinces = "<select name='usr_province'>
        <option>AL - Alabama</option>
        <option>AK - Alaska</option>
        <option selected='selected'>AZ - Arizona</option>
        <option>AR - Arkansas</option>
        <option>AA - Armed Forces America</option>
        <option>AE - Armed Forces Other Areas</option>
        <option>AP - Armed Forces Pacific</option>
        <option>CA - California</option>
        <option>CO - Colorado</option>
        <option>CT - Connecticut</option>
        <option>DE - Delaware</option>
        <option>DC - District of Columbia</option>
        <option>FL - Florida</option>
        <option>GA - Georgia</option>
        <option>GU - Guam</option>
        <option>HI - Hawaii</option>
        <option>ID - Idaho</option>
        <option>IL - Illinois</option>
        <option>IN - Indiana</option>
        <option>IA - Iowa</option>
        <option>KS - Kansas</option>
        <option>KY - Kentucky</option>
        <option>LA - Louisiana/option>
        <option>ME - Maine</option>
        <option>MD - Maryland</option>
        <option>MA - Massachusetts</option>
        <option>MI - Michigan</option>
        <option>MN - Minnesota</option>
        <option>MS - Mississippi</option>
        <option>MO - Missouri</option>
        <option>MT - Montana</option>
        <option>NE - Nebraska</option>
        <option>NV - Nevada</option>
        <option>NH - New Hampshire</option>
        <option>NJ - New Jersey</option>
        <option>NM - New Mexico</option>
        <option>NY - New York</option>
        <option>NC - North Carolina</option>
        <option>OH - Ohio</option>
        <option>OK - Oklahoma</option>
        <option>OR - Oregon</option>
        <option>PA - Pennsylvania</option>
        <option>PR - Puerto Rico</option>
        <option>RI - Rhode Island</option>
        <option>SC - South Carolina</option>
        <option>SD - South Dakota</option>
        <option>TN - Tennessee</option>
        <option>TX - Texas</option>
        <option>VI - U.S. Virgin Islands</option>
        <option>UT - Utah</option>
        <option>VT - Vermont</option>
        <option>VA - Virginia</option>
        <option>WA - Washington</option>
        <option>WV - West Virginia</option>
        <option>WI - Wisconsin</option>
        <option>WY - Wyoming</option>        
        </select>";
} else if ($province == "AR - Arkansas") {
    $provinces = "<select name='usr_province'>
        <option>AL - Alabama</option>
        <option>AK - Alaska</option>
        <option selected='selected'>AZ - Arizona</option>
        <option>AR - Arkansas</option>
        <option>AA - Armed Forces America</option>
        <option>AE - Armed Forces Other Areas</option>
        <option>AP - Armed Forces Pacific</option>
        <option>CA - California</option>
        <option>CO - Colorado</option>
        <option>CT - Connecticut</option>
        <option>DE - Delaware</option>
        <option>DC - District of Columbia</option>
        <option>FL - Florida</option>
        <option>GA - Georgia</option>
        <option>GU - Guam</option>
        <option>HI - Hawaii</option>
        <option>ID - Idaho</option>
        <option>IL - Illinois</option>
        <option>IN - Indiana</option>
        <option>IA - Iowa</option>
        <option>KS - Kansas</option>
        <option>KY - Kentucky</option>
        <option>LA - Louisiana/option>
        <option>ME - Maine</option>
        <option>MD - Maryland</option>
        <option>MA - Massachusetts</option>
        <option>MI - Michigan</option>
        <option>MN - Minnesota</option>
        <option>MS - Mississippi</option>
        <option>MO - Missouri</option>
        <option>MT - Montana</option>
        <option>NE - Nebraska</option>
        <option>NV - Nevada</option>
        <option>NH - New Hampshire</option>
        <option>NJ - New Jersey</option>
        <option>NM - New Mexico</option>
        <option>NY - New York</option>
        <option>NC - North Carolina</option>
        <option>OH - Ohio</option>
        <option>OK - Oklahoma</option>
        <option>OR - Oregon</option>
        <option>PA - Pennsylvania</option>
        <option>PR - Puerto Rico</option>
        <option>RI - Rhode Island</option>
        <option>SC - South Carolina</option>
        <option>SD - South Dakota</option>
        <option>TN - Tennessee</option>
        <option>TX - Texas</option>
        <option>VI - U.S. Virgin Islands</option>
        <option>UT - Utah</option>
        <option>VT - Vermont</option>
        <option>VA - Virginia</option>
        <option>WA - Washington</option>
        <option>WV - West Virginia</option>
        <option>WI - Wisconsin</option>
        <option>WY - Wyoming</option>        
        </select>";
} else if ($province == "AA - Armed Forces America") {

.... snip 3,059 lines of code ...

} else if ($province == "WY - Wyoming") {
    $provinces = "<select name='usr_province'>
        <option>AL - Alabama</option>
        <option>AK - Alaska</option>
        <option>AZ - Arizona</option>
        <option>AR - Arkansas</option>
        <option>AA - Armed Forces America</option>
        <option>AE - Armed Forces Other Areas</option>
        <option>AP - Armed Forces Pacific</option>
        <option>CA - California</option>
        <option>CO - Colorado</option>
        <option>CT - Connecticut</option>
        <option>DE - Delaware</option>
        <option>DC - District of Columbia</option>
        <option>FL - Florida</option>
        <option>GA - Georgia</option>
        <option>GU - Guam</option>
        <option>HI - Hawaii</option>
        <option>ID - Idaho</option>
        <option>IL - Illinois</option>
        <option>IN - Indiana</option>
        <option>IA - Iowa</option>
        <option>KS - Kansas</option>
        <option>KY - Kentucky</option>
        <option>LA - Louisiana/option>
        <option>ME - Maine</option>
        <option>MD - Maryland</option>
        <option>MA - Massachusetts</option>
        <option>MI - Michigan</option>
        <option>MN - Minnesota</option>
        <option>MS - Mississippi</option>
        <option>MO - Missouri</option>
        <option>MT - Montana</option>
        <option>NE - Nebraska</option>
        <option>NV - Nevada</option>
        <option>NH - New Hampshire</option>
        <option>NJ - New Jersey</option>
        <option>NM - New Mexico</option>
        <option>NY - New York</option>
        <option>NC - North Carolina</option>
        <option>OH - Ohio</option>
        <option>OK - Oklahoma</option>
        <option>OR - Oregon</option>
        <option>PA - Pennsylvania</option>
        <option>PR - Puerto Rico</option>
        <option>RI - Rhode Island</option>
        <option>SC - South Carolina</option>
        <option>SD - South Dakota</option>
        <option>TN - Tennessee</option>
        <option >TX - Texas</option>
        <option>VI - U.S. Virgin Islands</option>
        <option>UT - Utah</option>
        <option>VT - Vermont</option>
        <option>VA - Virginia</option>
        <option>WA - Washington</option>
        <option>WV - West Virginia</option>
        <option>WI - Wisconsin</option>
        <option selected='selected'>WY - Wyoming</option>        
        </select>";
} else {
    $provinces = "<select name='usr_province'>
        <option selected='selected'>AL - Alabama</option>
        <option>AK - Alaska</option>
        <option>AZ - Arizona</option>
        <option>AR - Arkansas</option>
        <option>AA - Armed Forces America</option>
        <option>AE - Armed Forces Other Areas</option>
        <option>AP - Armed Forces Pacific</option>
        <option>CA - California</option>
        <option>CO - Colorado</option>
        <option>CT - Connecticut</option>
        <option>DE - Delaware</option>
        <option>DC - District of Columbia</option>
        <option>FL - Florida</option>
        <option>GA - Georgia</option>
        <option>GU - Guam</option>
        <option>HI - Hawaii</option>
        <option>ID - Idaho</option>
        <option>IL - Illinois</option>
        <option>IN - Indiana</option>
        <option>IA - Iowa</option>
        <option>KS - Kansas</option>
        <option>KY - Kentucky</option>
        <option>LA - Louisiana/option>
        <option>ME - Maine</option>
        <option>MD - Maryland</option>
        <option>MA - Massachusetts</option>
        <option>MI - Michigan</option>
        <option>MN - Minnesota</option>
        <option>MS - Mississippi</option>
        <option>MO - Missouri</option>
        <option>MT - Montana</option>
        <option>NE - Nebraska</option>
        <option>NV - Nevada</option>
        <option>NH - New Hampshire</option>
        <option>NJ - New Jersey</option>
        <option>NM - New Mexico</option>
        <option>NY - New York</option>
        <option>NC - North Carolina</option>
        <option>OH - Ohio</option>
        <option>OK - Oklahoma</option>
        <option>OR - Oregon</option>
        <option>PA - Pennsylvania</option>
        <option>PR - Puerto Rico</option>
        <option>RI - Rhode Island</option>
        <option>SC - South Carolina</option>
        <option>SD - South Dakota</option>
        <option>TN - Tennessee</option>
        <option>TX - Texas</option>
        <option>VI - U.S. Virgin Islands</option>
        <option>UT - Utah</option>
        <option>VT - Vermont</option>
        <option>VA - Virginia</option>
        <option>WA - Washington</option>
        <option>WV - West Virginia</option>
        <option>WI - Wisconsin</option>
        <option>WY - Wyoming</option>        
        </select>";
}

"It was an easy fix... but it certainly didn't solve the bigger problem."

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!