Working on my predecessors code.... I've found this and went 'ugggh'



  • Please post your own 'uggghhh' moments.

    Working on my predecessors code.... I've found this and went 'ugggh'

    Clean and concise:
    Dim Option0, Option1, Option2, Option3, Option4, Option5, Option6, Option7, Option8, Option9, Option10 Dim Option11, Option12, Option13, Option14, Option15, Option16, Option17, Option18, Option19, Option20 Dim Option21, Option22, Option23, Option24, Option25, Option26, Option27, Option28, Option29, Option30 Dim Option31, Option32, Option33, Option34, Option35, Option36, Option37, Option38, Option39, Option40 Dim Option41, Option42, Option43, Option44, Option45, Option46, Option47, Option48, Option49, Option50 Dim Option51, Option52, Option53, Option54, Option55, Option56, Option57, Option58, Option59, Option99

    Here is one more: ugggh

    Response.write "<BODY><table width=660 border=0>"
    

    ShowBlankRow

    Response.write "<tr><TD ALIGN=CENTER colspan=2><FONT SIZE=+3><b>Company Name</b></FONT></TD></tr>"

    Response.write "<tr><TD ALIGN=CENTER " & RowColor & " colspan=2><FONT SIZE=+2><b>Business License Information</b></FONT></TD></tr>"

    Response.write "<tr><TD ALIGN=RIGHT colspan=2><b>Logged in as: </b>&nbsp" & GetFullUserName & "</TD></tr> "

    ShowBlankRow

    ShowLinkRow "business_license_data.asp", "Show Business License"

    Response.write "</table></body>"


  • 🚽 Regular

    A long time ago I worked on this really convoluted system in VB Script. It's been so long since I've worked on VB Script and have long since forgotten the syntax, so I'll just use pseudocode. The predecessor had the following:

    const CATEGORY_VALUE_BREAKFAST = 0;

    const CATEGORY_VALUE_LUNCH = 1;

    const CATEGORY_VALUE_DINNER = 2;

    //snip to html code

    <select name="category">
        <option value="0">Breakfast</option>
        <option value="1">Lunch</option>
        <option value="2">Dinner</option>
    </select>

    //snip to submit handling code


    var value = getOptionValue();

    if (value == CATEGORY_VALUE_BREAKFAST)
    {
    category = 0;
    }

    if (value == CATEGORY_VALUE_LUNCH)
    {
    category = 1;
    }

    if (value == CATEGORY_VALUE_DINNER)
    {
    category = 2;
    }

    To make matters even worse, there was a database table of categories which had the same category data. When I was tasked with the seemingly simple task of adding some new categories to the form to select from I saw the categories table and thought, "Hey, I'll just add these new categories in, make sure the form still works and move onto the next task."

    When I saw that the simple addition of table rows didn't do anything, I looked at the code you see above, and as you can imagine, my reaction was "Ugggh."

    I later found out that the categories table WAS in fact referenced, but only in the report of form submissions. So each of these separate dependencies were equally necessary to achieve the same thing. Later on as more and more categories came in I said 'screw it' and finally refactored the code so all one would need to do was add them into the database and everything else would work just fine.

    Just as you find often, people cannonized this predecessor as if he was the end-all-be-all of programmers. Me? I wasn't as impressed.


Log in to reply