8 ms·
Every single legacy application I've ever worked on has had analogous code buried in it somewhere. An application I've just been "repairing" recently has a spo
by Glyptodon 13y ago
Every single legacy application I've ever worked on has had analogous code buried in it somewhere.
An application I've just been "repairing" recently has a spot where it uses two separate queries to pull two full table sized lists of values, then manually joins them with a loop, and then manually re-orders the joined values into groups selectively ignoring some rows, and then embeds the the whole reordered list in a web page. The page takes around 20 seconds to load. Switching it to use a single properly formatted SQL reduced load times to under a second.
Another legacy app I'm employed to "repair" has one single 'template' for every page on the whole site. Its first ~500 lines conveniently consist of a giant and highly nested if/else clause to set the page variables and inline javascript.
Such things are the result of "IT experts," "Software Managers," and "Product Administrators" who've never done real software/web development in their lives hiring random "programmers" who have history or psychology degrees and think they can program because they made a form in PHP.
It only gets lovelier when eventually somebody realizes it's a huge security risk and hires an outside development firm to "secure" it. (Giant eye roll. If they couldn't vet a programmer, you can bet they're great at vetting security consultants and contract developer shops.) Did you know that randomly moving code into folders named "private" and "public" for a few thousand dollars can solve giant architectural and security issues like ridiculously easy XSS and SQL injection?
I don't know what the deal is, but a huge proportion of people writing code are plain incompetent.
At my last company we fired someone who created huge amounts of work for everyone (he thought he could secure page content and alert messages by using base 64 encoding as a stand in for hashing and encryption, for example) and a few months later he was hired as lead developer by a pretty reputable educational business.
... sigh
- sown 13y ago> Every single legacy application I've ever worked on has had analogous code buried in it somewhere. I'm not old enough to be responsible for stuff like that but I am incompetent enough.
- impressive 13y ago> I'm not old enough to be responsible for stuff like that but I am incompetent enough. Now that is a great conversation starter! I assume you think you know more than the senior/lead/architect on the team. You might, but have fun with that mentality. It's not sure to last. :)
- bnejad 13y agoWhat are you on about?
- rpedela 13y agoWhat?
- cema 13y agoYou must have misread the parent in an interesting way.
- kylemaxwell 13y agothe GP said "incompetent enough"
- aptwebapps 13y agoNot old enough as in hasn't produced any legacy code yet. Not in the sense of avoiding senility.
- petenixey 13y agoI love your comment. Funny and humble.
- sown 13y agoRest assured that while the person responsible for the legacy design flaw is perhaps long gone, I'll be right there...waiting, oblivious.
- jmadsen 13y ago>Another legacy app I'm employed to "repair" has one single 'template' for every page on the whole site. Its first ~500 lines conveniently consist of a giant and highly nested if/else clause to set the page variables and inline javascript. oh, oh! I'm doing one of those. Only, it's a modern, MVC version, so there's actually a couple of dozen controllers with a single function each, and all actions snake through The Great Maze of Ifelsedom to set their rightful values, before traversing it once more on the page view file Manager: "Uhm, I thought you said changing that label would be a 5 minute task?"
- umsm 13y agoWhenever something like that happens, this is my reference: http://developerexcuses.com http://developerexcuses.com
- evincarofautumn 13y ago> Switching it to use a single properly formatted SQL reduced load times to under a second. We need you to change it back because the system that scrapes that page is relying on the page load time.
- nwh 13y agoThat is, computer running the sign on the front of the store pulls data from here, and you've completely broken it because now the page loads a second time before it can finish drawing the screen. It /needs/ that delay on the HTTP request in order to catch up. A real programmer would have thought of that. Add some loops, sleeps and rands; we can talk about your reckless conduct in the morning.
- nnnnni 13y agoWhat's worse is when fake delays are put into the code because (stupid) people think that the computer can't possibly be doing a good job if it retrieves the results in under a second. If it's "thinking", it's working well!
- jbaiter 13y ago> hiring random "programmers" who have history or psychology degrees and think they can program because they made a form in PHP. That's pretty unfair to people coming from history or psychology who actually can write good code. Just because you don't have a degree in CS doesn't mean your code is shit. This is purely anecdotal, but my predecessor at my current job was a CS graduate and wrote code like in the OP.
- rmc 13y agoHere here. There are plenty of people who have CS degrees and can't programme. Why else do we need "FizzBuzz".
- TazeTSchnitzel 13y agoIt's "hear, hear!" - an abbreviation of "Hear him, hear him!".
- hcayless 13y agoSpeaking as a former history major, thanks! :-) Code like that is written by people who don't really understand how their code works and there are plenty of CS majors in that category. With any luck, they are swiftly promoted to management where they can do less harm.
- einhverfr 13y agoAs a history major, I would agree with you. One of the real issues has to do with the mentality of coding. There are people regardless of background who approach coding as a job, and those who approach it as a craft. You want the latter, not the former. Here's my rule: If you don't look back at code you wrote a decade ago with some degree of horror, you are either an extraordinarily good coder, or you aren't a good coder at all.
- etler 13y agoI'm starting to really dislike the term "legacy code". It implies the code is bad because it's old. It perpetuates the misconception that code gets "stale" and problems build up. But that's not true. "Legacy code" is bad because it's BAD. All code is "legacy code" because unless the project is brand new, it has some history. We just don't call good old code "legacy code" because it hasn't caused us any problems. There is no reason to correlate bad code with age.
- cperciva 13y agoI think you're misunderstanding the term. Legacy code -- like legacy lots of other things -- is the intersection of "bad" and "it's too late to fix now". Code which can be fixed easily isn't "legacy". Code where a replacement would need to be bug-for-bug compatible in order to avoid breaking things is "legacy".
- sopooneo 13y agoI've heard of that scenario, but I'm curious about what the best way to produce a bug-for-bug replacement would be. Should you do it right, and then put a layer in front of it that switches/transforms the output to match the old errors?
- ante_annum 13y agoMy favorite definition of legacy code is bad code for which no tests exist. It's terrible because people have no idea what to do with it and no idea what they're breaking when they change it. You could be writing legacy code today.
- andyroid 13y agoWhile code may not go bad with age, the surrounding world (compilers, frameworks, dependencies) change constantly. So while the code quality of a million LOC Java 1.0 application might be stellar, maintaining it may still be a royal pain. So in one way code does get "stale" when left untouched for too long.
- danielweber 13y ago
- skizm 13y ago> I don't know what the deal is, but a huge proportion of people writing code are plain incompetent. Hooray for short term job security!