$inputFD[2] = "The neighborhood bycicle"



  • I'm working with some pretty attrocious code. Every line contains at least one wtf. I've become kind of numb to them by now. But this one was a perfect argument for coding correctly, and not coming up with "clever tricks". You should never have to "trick" the computer into doing what you want. Coding should be intentional, not magical.

    So anyways, I'm working with a script that takes a radius and inserts all of the zip codes within that radius into a database. The new radius is passed through the header as "inputFD[2]", instead of "newRadius" (or something logical like that). Well, the same page (consisting of 10 different files ranging from 300-1200 lines of mostly uncommented code) used in a different context, unbeknownst to me, also passes a list of zipcodes to be inserted into a different DB table through, you guessed it, a header variable called "inputFD[2]" instead of something logical like "zipList".

    Shortly after testing (quickly) and launching an update to this page we started getting jobs that would be assigned every zipcode in the entire USA. We were confused at first. I wrote the code that did the assignment, but I had very little knowledge of the insane spaghetti code that I was inserting this code into. I assumed that inputFD[2] was only ever a zipcode radius, and also assumed that the place I was putting the code to do the insert was only ever run when they were actually working with zipcode radii. These are the sort of assumption one has to make when your boss wants something done NOW.

    By now you may have realized what happened. There is another view of the page that I had no knowledge of where the user can enter a list of zips and it will be passed through the inputFD[2] variable and parsed by my script as if it were a radius, resulting in the script thinking the job has a radius of "27943,23817,23481,23492,..."(etc, etc, up to 500 zips) and therefor in some cases encompasing the entire universe.

    sigh.

    Please give your variables a clear name and one purpose. PLEASE.

    Oh, and this is the from the same PHP page that was the topic of this post. I could probably fine 100 other gems like this in the code in that page...



  • @cmcculloh said:

    (etc, etc, up to 500 zips) and therefor in some cases encompasing the entire universe.

    I was unaware we had assigned ZIP codes to the entire universe. Is that what the four-digit extension is for?



  • @bstorer said:

    @cmcculloh said:
    (etc, etc, up to 500 zips) and therefor in some cases encompasing the entire universe.

    I was unaware we had assigned ZIP codes to the entire universe. Is that what the four-digit extension is for?

     

     

    Yeah, but no, there's actually an extra nine-digit extension you can use for intergalactic zips. It only works for the milky way though, after that they start using greek lettering preceeding the zip...



  • I'll tell you a little secret about zip codes: they're meaningless. Mwahahaha!



  • The Zip codes ... They Do Nothing! 



  • @brianmcculloh said:

    I'll tell you a little secret about zip codes: they're meaningless. Mwahahaha!

     

    Did you forget your username and just register a new one?

    WTF?



  • No, that was my first post. Did I do something wrong? 



  • @brianmcculloh said:

    No, that was my first post. Did I do something wrong? 

     

    No but on your second post, quoting who you were referring to would help.



  • @brianmcculloh said:

    No, that was my first post. Did I do something wrong? 

     

    I think he is confused because we have the same last name. Probably thought I forgot my password or something and reregistered as "brianmcculloh"... 



  • @MasterPlanSoftware said:

    @brianmcculloh said:

    No, that was my first post. Did I do something wrong? 

     

    No but on your second post, quoting who you were referring to would help.

     

     

    LOL, this is my third and final post. I apologize to tdwtf for any inconvenience. Goodbye. 



  •  No Brian! Don't leave us!



  •  @superjer said:

     No Brian! Don't leave us!

    At this rate, we'll have another 5 McCulloughs signed up before he'll even get a chance to see that post.. 



  • I'm so glad we have MasterPlanSoftware here to tell newbies how to post.



  • @merreborn said:

    I'm so glad we have MasterPlanSoftware here to tell newbies how to post.

     

    If he couldn't take the 'brutality' of someone mentioning the quote button, he wasn't going to last here long anyway. You would have a valid complaint if I flamed him for it, but I didn't.

    Stop being an asshole and trying to stir shit up.



  • @merreborn said:

    I'm so glad we have MasterPlanSoftware here to tell newbies how to post.
    MPS did not tell anyone how to post in this thread, but merely noted the confusion caused by the similar usernames.  I wish newbies didn't need to be told how to post and that people would not post sarcastic flamebait disguised as seemingly-innocent comments.



  • @MasterPlanSoftware said:

    @brianmcculloh said:

    No, that was my first post. Did I do something wrong? 

     

    No but on your second post, quoting who you were referring to would help.

     

    LOL!  He was quoting Newman.


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.