Model ALL the controllers!



  • where i work now, there's one very common (it's everywhere, to be more precise) MVC antipattern - no
    idea if it has name, but i'd call it M-C mirroring? basically, the
    former programmer of systems i now maintain didn't really get the whole
    MVC thing, so every controller has its special model, regardless of what
    it uses - example: the site works with sales, it shows list of current
    sales on one view, and enables you to order something from any of them (in another view, belonging to another controller). sane person (or i, at least)
    would make one "sales" model and implement functions to get the list from db, to order one, to get list of customers who ordered specific sale, etc.

    nope, here i have controller called "other" (naming is another WTF), which handles the main page and the sales lists, which uses a model named mother (read m-other, it's still funny sometimes), which has functions to get list of sales filtered and sorted according to various criteria, and details of a sale from an id.

    and then i have controller called "buy" that handles the ordering process, and its truthful companion mbuy, which contains at least 3 functions identical to what is in mother (get details of sale from id, get list of sales (don't ask me why we need that when submitting orders)), etc.

    this goes through the whole project (which is a software package we sold to at least 30 customers), every controller has its own model, and every model contains at least 2-3 functions that are in at least one other model, complete with the same name, parameters, and functionality (at least it's consistent), and when there's controllers which operate on the same data, only in different ways, the models tend to get pretty similar to each other, to the point where i found one being an exact duplicate (though written by hand, separately, no copy-pasting) of other one, just with one extra function...

     

    (and then there are some minor WTFs like having no source control or testing servers, doing all the modifications the clients want directly in their live version, not even downloading the sources (PSPad with its ability to edit files directly through ftp is handy)), so when something screws up, all i can (and have to) do is some psychic debugging, or editing the source adding error_reporting(E_ALL) on the beginning of file, saving, refreshing the (live, official, public) page to see the errors, and quickly go back to source, comment out the error_reporting command, and save again... but it at least teaches/makes me think and edit strategically when adding new functionality - bottom up: add new function to model first, so the app doesn't crash on calling something that doesn't exist, save, check if i broke anything, then make the function accessible/use it in controller, save and check again, then add the button/whatever to view to actually make it available.)

     

    not really a rant, i got used to it, and it at least sometimes makes the programming as thrilling as it looks in all the hacker movies. it just amuses me, mainly that this is considered common and normal practice in our country even for mid-sized businesses (if you can call national news information service mid-sized, which you probably can, in a country with 6 milion people).

    (if you want to see me working today, periodically refresh zlava.odpadnes.sk and zlavy.odpadnes.sk and watch if you notice the changes)



  • @SEMI-HYBRID code said:

    doing all the modifications the clients want directly in their live version, not even downloading the sources

    I've been in this situation once (having no testbed and just changing it on production) - so I began leaving testing stuff open for view during deployment. 

    Manglement finally understood that making changes to production was a bad idea - not because of the inability to safely undo changes nor interruptions to live service, but the expose of changes to the world as they were being done. And thus I ended up with a testbed.



  • "zlavy.odpadnes.sk"

    I Like the colors!



  • @ubersoldat said:

    "zlavy.odpadnes.sk"

    I Like the colors!

    I like the translation!
    @zlavy.odpadnes.sk said:

    DISCOUNTS certain of which waste!

    It reminds me of a tourist brochure a cow-orker picked up in Azerbaijan, encouraging the reader to, "Visit the Hairy Caspian!" I like to think that it was just a very oblique promotion of the local sex tourism.

    Anyways, TRWTF is editing production code over FTP. Jeez, at least use sftp.



  • @SEMI-HYBRID code said:

    (and then there are some minor WTFs like having no source control or testing servers, doing all the modifications the clients want directly in their live version, not even downloading the sources (PSPad with its ability to edit files directly through ftp is handy)), so when something screws up, all i can (and have to) do is some psychic debugging, or editing the source adding error_reporting(E_ALL) on the beginning of file, saving, refreshing the (live, official, public) page to see the errors, and quickly go back to source, comment out the error_reporting command, and save again... but it at least teaches/makes me think and edit strategically when adding new functionality - bottom up: add new function to model first, so the app doesn't crash on calling something that doesn't exist, save, check if i broke anything, then make the function accessible/use it in controller, save and check again, then add the button/whatever to view to actually make it available.)

    ...

    (if you want to see me working today, periodically refresh zlava.odpadnes.sk and zlavy.odpadnes.sk and watch if you notice the changes)

    Yup. Been there. Except it wasn't websites, but the code behind basic office infrastructure. But don't worry, it was only minor code-tweaking and bugfix testing that we routinely did on clients' live systems. Minor in the sense of "it should only take an hour or so, and won't break anything if your're careful" (In work hours of course, since the company couldn't afford overtime - can't imagine why not!).

    We were much more sensible when it came to really big changes, actual development work. What we did then was use our own office system.
    But I'm sure no (actual or potential) customers would have thought any less of us when they couldn't communicate with us for a day or two every so often. We were only a communications company, after all.



  • @boomzilla said:

    It reminds me of a tourist brochure a cow-orker picked up in Azerbaijan, encouraging the reader to, "Visit the Hairy Caspian!"

    ObEngrish: BMW's tagline at one time was "guaranteed to move the spirit."

    This was translated into "liable to reanimate your dead ancestors" on billboards over in Japan.

    ObRerail: Agree with the SFTP rather than FTP. IIS used to have an FTP engine... does it support FTPS, does anyone know?



  • @Cassidy said:

    @boomzilla said:

    It reminds me of a tourist brochure a cow-orker picked up in Azerbaijan, encouraging the reader to, "Visit the Hairy Caspian!"

    ObEngrish: BMW's tagline at one time was "guaranteed to move the spirit."

    This was translated into "liable to reanimate your dead ancestors" on billboards over in Japan.

     

    That sounds like the urban legend about General Electric, where "we bring good things to life" got translated as "we bring your ancestors back from the dead" in China.

     



  • @Justice said:

    @Cassidy said:

    @boomzilla said:

    It reminds me of a tourist brochure a cow-orker picked up in Azerbaijan, encouraging the reader to, "Visit the Hairy Caspian!"

    ObEngrish: BMW's tagline at one time was "guaranteed to move the spirit."

    This was translated into "liable to reanimate your dead ancestors" on billboards over in Japan.

     

    That sounds like the urban legend about General Electric, where "we bring good things to life" got translated as "we bring your ancestors back from the dead" in China.

     

    Or the PaperMate pen one where something along the lines of "Leak-proof" got translated to "Won't get you pregnant".


  • @Jaime said:

    @Justice said:
    @Cassidy said:
    @boomzilla said:
    It reminds me of a tourist brochure a cow-orker picked up in Azerbaijan, encouraging the reader to, "Visit the Hairy Caspian!"
    ObEngrish: BMW's tagline at one time was "guaranteed to move the spirit."

    This was translated into "liable to reanimate your dead ancestors" on billboards over in Japan.

     That sounds like the urban legend about General Electric, where "we bring good things to life" got translated as "we bring your ancestors back from the dead" in China.
    Or the PaperMate pen one where something along the lines of "Leak-proof" got translated to "Won't get you pregnant".
    Lets just get all of the big ones out of the way:



  • @SEMI-HYBRID code said:

    (and then there are some minor WTFs like having no source control or testing servers, doing all the modifications the clients want directly in their live version, not even downloading the sources (PSPad with its ability to edit files directly through ftp is handy)), so when something screws up, all i can (and have to) do is some psychic debugging, or editing the source adding error_reporting(E_ALL) on the beginning of file, saving, refreshing the (live, official, public) page to see the errors, and quickly go back to source, comment out the error_reporting command, and save again... but it at least teaches/makes me think and edit strategically when adding new functionality - bottom up: add new function to model first, so the app doesn't crash on calling something that doesn't exist, save, check if i broke anything, then make the function accessible/use it in controller, save and check again, then add the button/whatever to view to actually make it available.)

    Are you not ALLOWED to download the code and run it locally or something? Just because your cow-orkers (tm) edit the live code on the production server doesn't mean YOU have to as well...



  • @Justice said:

    That sounds like the urban legend about General Electric, where "we bring good things to life" got translated as "we bring your ancestors back from the dead" in China.

    I thought that was "Come alive with the Pepsi generation"...



  • @SEMI-HYBRID code said:

    where i work now, there's one very common (it's everywhere, to be more precise) MVC antipattern - no
    idea if it has name, but i'd call it M-C mirroring? basically, the
    former programmer of systems i now maintain didn't really get the whole
    MVC thing, so every controller has its special model, regardless of what
    it uses - example: the site works with sales, it shows list of current
    sales on one view, and enables you to order something from any of them (in another view, belonging to another controller). sane person (or i, at least)
    would make one "sales" model and implement functions to get the list from db, to order one, to get list of customers who ordered specific sale, etc.

    MVC deserves a prize for "most consistently incorrectly-implemented pattern". You'd think if somebody was bothering with MVC they'd at least be in the top 50% or so, but I've seen so many wacky implementations. It's made worse by the web MVC stuff. I mean, yeah, it's kind of MVC-ish, but I think calling it MVC was a bad idea since it wasn't creating an event-driven GUI. And now that Javascript is powerful enough to handle real MVC you've got people who only ever learned web MVC trying to transfer the ideas over to real MVC which is just ass-backwards..

    @SEMI-HYBRID code said:

    (and then there are some minor WTFs like having no source control or testing servers, doing all the modifications the clients want directly in their live version, not even downloading the sources (PSPad with its ability to edit files directly through ftp is handy)), so when something screws up, all i can (and have to) do is some psychic debugging, or editing the source adding error_reporting(E_ALL) on the beginning of file, saving, refreshing the (live, official, public) page to see the errors, and quickly go back to source, comment out the error_reporting command, and save again... but it at least teaches/makes me think and edit strategically when adding new functionality - bottom up: add new function to model first, so the app doesn't crash on calling something that doesn't exist, save, check if i broke anything, then make the function accessible/use it in controller, save and check again, then add the button/whatever to view to actually make it available.)

    I love PHP but I hate that it's made this "edit it on production" mentality possible.



  • @morbiuswilters said:

    And now that Javascript is powerful enough to handle real MVC you've got people who only ever learned web MVC trying to transfer the ideas over to real MVC which is just ass-backwards..

    It actually can get even worse: try dealing with developers that are completely comfortable working with MVC (or bastard-child MVP) on the server side, but can't manage to grok the same separation of concerns client side. I had an interesting discussion some months ago after using a simple MVC pattern to provide some much needed structure and control flow to a complex piece of client-side logic. It ended in a request to revert those changes and return to unstructured, unmaintainable spaghetti mess, because the client's own inhouse development team "isn't comfortable working with MVC in JavaScript".



  • @boomzilla said:

    DISCOUNTS certain of which waste!
     

    oh, sorry, yes, the whole time i was writing the post i kept thinking that sales isn't really the word i'm looking for, but i couldn't remember the right one.



  • @boomzilla said:

    Anyways, TRWTF is editing production code over FTP. Jeez, at least use sftp.
     

    sftp? i don't even know if it has one, all the sites are on different hostings at different companies, they own the hosting/server configs, and i don't have time to look in them, never mind trying to change them/convince the customer to change them...



  • @token_woman said:

    We were much more sensible when it came to really big changes, actual development work.
     

    there's no big changes in discount-land, it's like real evolution - branches of code diverge constantly in small increments to accomodate their environment (hosting, user/customer of that specific copy) up to the point where you get two different species that cannot mate. not even the bugfixes are deployed globally, because firstly there's no way to, secondly everybody assumes that bug we just fixed at one customer doesn't appear at any other customer because it's different from this one, and thirdly because noone really cares/minds it. why fix it before specific customer reports it? he may never even encounter it, so there's one unnecessary bughunt avoided.



  • @ekolis said:

    Just because your cow-orkers (tm) edit the live code on the production server doesn't mean YOU have to as well...
     

    what coworkers? my boss is the owner of the firm, marketing and graphics designer, knows some php but doesn't like programming so he hired me, one coworker is a graphics designer only, and my second coworker... damn, i kind of have no idea... we're basically a basement company.

    Edit: oh yeah, the actual answer: i am allowed, but it takes quite a time and even i don't like it... i mean - try to download, open, edit, save and upload a file every time you make a change, when all those changes are quite often of the "edit one line, see how it affects the rest of the system" nature...



  • @SEMI-HYBRID code said:

    sftp? i don't even know if it has one, all the sites are on different hostings at different companies

    Did you look? Did you advise them that unencrypted access to their servers could be violating compliance somewhere? It's easier to convince those that run a shopping basket or some other part of their site over HTTPS, but you can guarantee that if those sites are compromised as a result of sniffing credentials out, fingers are going to start pointing at you (despite it not being your business decision, you can still get it in the neck for knowing about this technical stuff and not raising awareness).

    @SEMI-HYBRID code said:

    they own the hosting/server configs , and i don't have time to look in them, never mind trying to change them/convince the customer to change them...

    .. but do they actually know what they're doing? Valuable consultancy opportunity missed there.

    @SEMI-HYBRID code said:

    why fix it before specific customer
    reports it? he may never even encounter it, so there's one unnecessary
    bughunt avoided.

    Proactive is better than reactive, and it ain't the customer's fault the bug was introduced, so responsibility rests in your hands. Again, I can see a situation in which when the bug comes to light, someone's going to demand how/why buggy code was introduced to the production site, bugs that could accrue sizable cost via downtime.

    @SEMI-HYBRID code said:

    my boss is the owner of the firm,
    marketing and graphics designer, knows some php but doesn't like
    programming so he hired me

    .. as a simple code monkey, or as someone that knows more about these issues then he does and can offer him useful advice to make more informed business decisions about his clients and customers?

    I'm not disagreeing with the situation your in, how it came about or who's fault it is - more your attitude to it.



  • @SEMI-HYBRID code said:

    @boomzilla said:
    Anyways, TRWTF is editing production code over FTP. Jeez, at least use sftp.

    sftp? i don't even know if it has one, all the sites are on different hostings at different companies, they own the hosting/server configs, and i don't have time to look in them, never mind trying to change them/convince the customer to change them...

    It's OK. The way in which you access the servers is the least of your problems, really.



  • Not denying the WTF's in this example, but having a dedicated model is a proper application of MVVM, which in many cases have replaces MVC. The  View Model (last two characters of MVVM) expose just the minimum model necessary to support the specific view.


Log in to reply
 

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