D4t4b4s3 r0x3z



  • I should be going to work right now, but I'm going to spend a few minutes with you guys (naturally, I don't have a social life), because I would like to share with you the current model of the application I've been working on in the past six months. The amount of legacy code is simply huge. Now, I'm a good programmer - not an expert - and I agree with almost everything I've read in Code Complete, I'm very passionate about my work and if I could, I would marry my work. My boss constantly reviews my code and guides me where I've overengineered things so my code is far from perfect, but the legacy code I've found is simply terrible and for a while, I even had nightmares about it... There's still a lot of it I didn't understand but here's what I've found until now:

    The original designers of this web application thought it would be a good idea to automate everything. We're talking about an application that mainly has to change some records in a database and launch an application on the system so why not create an automated system that you just configure and it creates its own menu based on a structure given in the database? Each page should be attached to a table and the insert/delete/update queries should also be *in* the database so if you had something like a record in the menu table, you'd have a few other records in a form table that connected that record from menu with other records from form_query and each one had its own type: insert / update / delete. If the user was only able to change a setting (like enable/disable something) then you only had one record in form_query which pointed to an update query in the query table. Yes, the records in the query table are queries themselves and they are parametrized using $variable constructs. How do they replace the $variable with its value? Using eval() in PHP!

    But you need to design the web interface a bit, right? You can't just give the user <input type="text"> fields, because there are some enum columns. For that, they instantiate a class with the name given in the menu table. Again, using eval(). Of course, some fields were <select> and their values were supposed to be taken from another table so those fields also have some queries defined in the database (not sure where...). Let's not forget about the fields that require validation, like IP/netmask, for those you specifically tell it somewhere (in the fields table, I think) what type they are and the application automatically includes JavaScript validation code for it. There are lots of other types which are validated by JS functions such as function CheckBoolean(value) { return true }.

    I'd say that about 95% of the application is in the database and eval() calls. Because of this, you'd have a whole page specificallly designed for an enable/disable button and a whole page specifically designed for a password field and they were connected - one enables SSH and the other sets the password. Want to add a field in the database? No problem! You only have to hunt down the page which you're looking for in form then go to form_query, then to query and change the queries...

    TRWTF? They actually thought they could get away with it. They had a vision where they would just add some records in the database and they had a brand new page for adding/editing/deleting records and, if they wanted, they could only change the application design in one place and pray it wouldn't break everything else. AJAX? What's AJAX? If you just clicked a button that was supposed to change from red to green, you'd have to wait for the whole 1MB page to reload. CSS? Who needs it! As long as the application works, you don't need it to look friendly. I mean, look at the Cookie Monster - it's a monster, but kids like it! Master-detail relationships? Just throw another database table at it!

    Who wants a cookie?

    Great, now I'm late for work. I hope you can sleep at night knowing this.



  • @rohypnol said:

    I hope you can sleep at night knowing this.
     

    I sleep more deeply, knowing that it's your problem, and that I can focus on destroying the images in my head of Belgarion's weavable  floppy.



  • I do not envy your position one bit.@rohypnol said:

    now I'm late for work. I hope you can sleep at night knowing this.
    yes, I can happily sleep at night knowing that you are late for work ... or did I misunderstand something there? :P



  • @rohypnol said:

    They actually thought they could get away with it.
    And they would have if not for you meddling kids!

    Given where you're from, I'm waiting for the part where this app ties to the boy band Ozone.  Don't lie, I know it revolves around worshipping them as the ones who put Romania on the map.



  • @belgariontheking said:

    @rohypnol said:

    They actually thought they could get away with it.
    And they would have if not for you meddling kids!

    Given where you're from, I'm waiting for the part where this app ties to the boy band Ozone.  Don't lie, I know it revolves around worshipping them as the ones who put Romania on the map.

     

    Not really. It depends where you're from - if you're from the US then yes, Ozone did that. If you're from the UK then it was Cheeky Girls. Anyway, all our "stars" are from Moldova. They were starving people who accepted to get fcked in the ass for some fame and fortune. This was admitted publicly by some of them and the process goes something like this: they prostitute themselves locally, they try to get in touch with celebrities, they use them to get celebrities themselves, they go to foreign countries from Europe where they prostitute themselves for money, they come back to Romania and spend the money to get more fame which they use the prostitute themselves abroad again...



  • @belgariontheking said:

     the ones who put Romania on the map.

     

    I thought that was Count Chocula?



  • There are tiny little pieces of good model-driven ideas there, but in a WTFy way.



  • @belgariontheking said:

    boy band Ozone.

    I saw their album when I was in Romania. Next to it, there lay a few System Of A Down albums. On audio cassettes.

    That was the most hilarious thing I've ever seen.



  • @belgariontheking said:

    Don't lie, I know it revolves around worshipping them as the ones who put Romania on the map.

    They have Romania on maps now?  Groovy.



  • @derula said:

    @belgariontheking said:
    boy band Ozone.

    I saw their album when I was in Romania. Next to it, there lay a few System Of A Down albums. On audio cassettes. That was the most hilarious thing I've ever seen.

    Ah, Romania... visited a few years after they shot that prick Ceausescu. I saw a lot of hilarious things. And by hilarious I mean depressing.

    There are two things that changed for me after that. One is that I learned to appreciated how incredibly lucky I am to have been born in a democratic, capitalist country. The other is that I developed a deep hatred of communist ideals.These days when I see those fuckwit communist-wannabe students living on daddy's money with their trendy clothes and fashionable mobiles protesting in the street, I get the urge to go on a shooting spree.

     



  • @DOA said:

    There are two things that changed for me after that. One is that I learned to appreciated how incredibly lucky I am to have been born in a democratic, capitalist country. The other is that I developed a deep hatred of communist ideals.These days when I see those fuckwit communist-wannabe students living on daddy's money with their trendy clothes and fashionable mobiles protesting in the street, I get the urge to go on a shooting spree.

    Ditto that.



  • @morbiuswilters said:

    @belgariontheking said:

    Don't lie, I know it revolves around worshipping them as the ones who put Romania on the map.

    They have Romania on maps now?  Groovy.

     

    Romania - Simply Surprising (and there are many better ones, but I'm too lazy to look for them now; maybe you could stop being such an ignorant prick and maybe you're not such a "genius" as you call yourself, it seems there's lots of stuff out there you still don't know)



  • @rohypnol said:

    @morbiuswilters said:

    @belgariontheking said:

    Don't lie, I know it revolves around worshipping them as the ones who put Romania on the map.

    They have Romania on maps now?  Groovy.

     

    Romania - Simply Surprising (and there are many better ones, but I'm too lazy to look for them now; maybe you could stop being such an ignorant prick and maybe you're not such a "genius" as you call yourself, it seems there's lots of stuff out there you still don't know)

    So the surprising part is that Romania has shelter and a road?  Because I figured there was some sort of road in Romania.  How else would you take goats to market to barter for Gypsy treasure?



  • @morbiuswilters said:

    @rohypnol said:

    @morbiuswilters said:

    @belgariontheking said:

    Don't lie, I know it revolves around worshipping them as the ones who put Romania on the map.

    They have Romania on maps now?  Groovy.

     

    Romania - Simply Surprising (and there are many better ones, but I'm too lazy to look for them now; maybe you could stop being such an ignorant prick and maybe you're not such a "genius" as you call yourself, it seems there's lots of stuff out there you still don't know)

    So the surprising part is that Romania has shelter and a road?  Because I figured there was some sort of road in Romania.  How else would you take goats children to market to barter for Gypsy treasure?

    FTFY


  • @bstorer said:

    @morbiuswilters said:

    @rohypnol said:

    @morbiuswilters said:

    @belgariontheking said:

    Don't lie, I know it revolves around worshipping them as the ones who put Romania on the map.

    They have Romania on maps now?  Groovy.

     

    Romania - Simply Surprising (and there are many better ones, but I'm too lazy to look for them now; maybe you could stop being such an ignorant prick and maybe you're not such a "genius" as you call yourself, it seems there's lots of stuff out there you still don't know)

    So the surprising part is that Romania has shelter and a road?  Because I figured there was some sort of road in Romania.  How else would you take goats children to market to barter for Gypsy treasure?

    FTFY

    Yeah, but the children of Romania are more malnourished and diseased than the goats.  I know which I would prefer eating.


Log in to reply