Ask Slashdot: How To Avoid Working With Awful Legacy Code?
kramer2718 writes "I have worked for about a decade as a software engineer. I am almost never hired to build new software from scratch, so my work satisfaction tends to be proportionate to quality of the legacy code I have to work with. Some legacy code has been good. Most of it is bad. I know a few questions to ask during an interview to determine the code quality: Are recent technologies used? Are there code review processes? Is TDD practiced? Even so, I still encounter terrible quality code. Does Slashdot have any advice for other questions to ask? Any other ways to find out code quality beforehand?"
Not sure how those questions would indicate, you didn't specify. I could see some thinking "recent" technology means "good", but my personal experience provides little evidence to correlate "new technology" with good. I could even make a case that it's a red flag. (I worked on a disastrous project where by fiat we had to develop with .NET. Horrible)
Code reviews? Meh. Some think they're doing code review, they're not... or they're horrible at it.
I always ask what their turnover is, and why the position being filled was vacated. YMMV.
It's you. Stop being such a prick. The next guy hired to clean up your mess probably says the same things about you.
Ask the questions you are talking about. Phrase them as ways of showing your background in those areas. Ask what kind of standards they follow, so as to see if you know them. Ask if they are maintaining legacy code, to show you have experience. If the answers are too much for you, move on.
"Do you have a code sample I can look at?"
Work for a startup. Any place that has been around for any significant length of time is likely to have legacy code.
Realistically, a startup could very well have legacy code too, but it's likely to have much less if it has any. In effect, you'll be the one making the legacy code for those who come after you (or yourself, if you stick around that long.)
Not sure why legacy code is such a problem though. If it works and works well, why replace it? And if it doesn't work, it should have already been replaced.
That's what I would go after... if you only have the "old guys" then the environment is usually not something I would enjoy - too much inbreeding of ideas, no new technologies and such... Not necessarily bad code - just outdated. If there are only junior people there, then its a mess, nobody has the needed experience or a vision of a better future.
All decent code bases I ever touched in a commercial environment had a few older guys that stuck with the product cause its stable, easy work and a few newer guys because its a easy to learn, guided environment...
If the company relied on one programmer to handle everything, beware.
Try not. Do or do not, there is no try.
-- Dr. Spock, stardate 2822-3.
Work for a startup that has no legacy code.
"To those who are overly cautious, everything is impossible. "
Do you use CVS? Any kind of? No?.....
If they have a culture where the developers are allowed to focus on code quality, then if it's "bad code" (as subjective as that term is) you'll have a shot at fixing it. Code quality is a result of developer experience and the required development pace; the worst situation you can be in is where 100% of engineering time is spent on feature development and bug fixes, with no time allotted for maintenance work.
But like a poster above said, if you really are just sick of legacy code, work for a startup; that's what I did.
Don't use Windows. Duh
Find a job where you get to write code from scratch. Amidst all the changing requirements, last-minute fixes, impossible deadlines, and lip-service paid to best practices, you'll quickly meet the enemy, and he is you.
I have been coding for almost 20 years. I've been hiring people for a good part of that time.
Most employers reward their tenured developers with the new projects. The reasons are not always perfect, but, the simple answer is that they cut there teeth on legacy code, they understand the requirements, and they should know the pitfalls to avoid. If you are moving around a lot, you will find it more difficult to work on new stuff.
That being said, most companies want to put their best person on the job. If you have tenure but never showed initiative, dedication and team work attitude, you will usually be looked upon as not interesting to the leaders who are trying to show management that they have e right people to carry out a new project. After all, a new project is a risk to management that you are mitigating with proven people.
There are times you bring exactly the right experience to a company and you get fast tracked. New teams sometimes need entry level type devs to fill in to write he muck code. Or you get into a startup. These tend to be why people get the fun stuff right off. But most likely, they want you to prove yourself and understand the problem before you get the reward of new development.
How about you fix you?
Rather than trying to avoid horrible legacy code, admit that the world is built out of horrible legacy code. Get hold of Martin Fowler, “Refactoring” and Michael C Feathers, “Working Effectively with Legacy Code” then develop your skills at working with legacy code to turn it into better code.
After all, that new beautiful code that you wrote for that last job is now someone else's horrible legacy code.
It is a matter of perception & expectation management.
The key is to find a place where you can work unseen to create your own horrible code with the hopes that in time you too will become the stuff of legend.
-Lod
No one likes dealing with legacy code. Any given developer has had to sit down and wade through code that's some combination of poorly designed, undocumented, non-functional, over-engineered, slow, tedious, failure prone and in all other ways apparently designed only to make your life some sort of hell of bleeding eyeballs and migraines - and that's just the code they wrote 3 months ago. Other people's code is worse.
Having written code for nearly 2 decades now, what I can tell you is this: It doesn't matter much. We all want to live in a land of beautiful code - if we didn't, we wouldn't get so upset when we see horrible code. However, the end game is: does it work? Yes, you want to wipe it out and start from scratch, and yes, it'll be a joy to work with after that (until the next guy shows up), and yes, it takes forever to make a change, and yes there's no unit tests, and yes it's loaded with bad hacks - but for a business the real questions are "does it work?".
If the answer is 'yes', you're fighting an uphill battle to correct it. If you are lucky enough to be able to put a cost on it - time or dollars - that could be saved by refactoring, then perhaps you have the ammo required, but if you can't give a realistic metrics-backed analysis of it, then there's no business need to fix it.
Think about that for a bit: The need to fix it is not based on how broken you perceive it to be, but on entirely separate measures of no worth to you that require discrete and specific values.
(Besides, if you spent that time analyzing, now you know the system pretty well, so you're the new expert!)
More realistically, there's always going to be a next, new thing that needs to be built. If you spend all your time fixing problems that aren't 'too' broken, you'll miss all the chances you'll have to work on the new stuff, where you don't have to work on legacy code at all!
So the advice to you is what all good programmers should hate to hear, but know in their hearts to be true: Spend as little effort on it as possible, and move on, until it becomes a large enough problem that it requires attention, not just deserves it.
Oh - and if you have a good dev manager, ignore all that. Tell him it needs to be refactored, let him work out the priorities and schedules, and you're set. Also, while you're visiting Fantasy Island, tell Ricardo Montalban that he was awesome in Star Trek II.
Other people's bad code keeps me in business. If half of this crap were written well, no one would need me. Don't avoid bad code, dive in, clean it up where sensible, and move stuff forward.
I'm not sure where the story title "How To Avoid Working With Awful Legacy Code" came from, but it already sounds bad. Let's go on.
I have worked for about a decade as a software engineer.
So you've got enough miles under your belt to know more or less what you're doing, without being amazing. Ten years isn't very long for a discipline like programming, unless you do very basic stuff and never have to worry about optimization, for instance.
Some legacy code has been good. Most of it is bad.
Yeah? Really? See my comment above. By the way, the guy who comes after you probably says the same thing about most of your code. He's probably at least half right, too.
my work satisfaction tends to be proportionate to quality of the legacy code I have to work with
Perhaps I'm being unfair, but you do come across as a bit of a prima donna. And again, if you've only been doing this for ten years, then you probably aren't justified in being so snotty.
My work satisfaction tends to be proportionate to how much I get paid and how nice the other people are. If it was a party and fun all the time, it wouldn't be called "work". Yes, I enjoy my job. Yes, I know people will doubtless respond with "life is too short to work at a job you hate". But getting paid a small fortune can make a job an awful lot more fun. Look, I've worked for complete jerks, and sometimes you just have to walk away. I've done it. And then, sometimes, you just have to suck it up and be a grown-up.
If you can afford to turn your nose up at work that doesn't meet some random enjoyment factor criterion, then you're in a very fortunate position, and I hope you are grateful for how lucky you are. If you are in that kind of position, then you probably don't really need to be asking this question. Pick and choose as you want.
And if the code is really that bad, look at it as a challenge to your abilities, gleefully rub your hands together as you contemplate an extended contract and some security, and put together a spreadsheet to show how much money you're about to rake in. You never know, it might work and make the job a little bit more appealing, even if the code quality isn't up to your superior standards.
Are recent technologies used? Are there code review processes? Is TDD practiced? Even so, I still encounter terrible quality code.
That's because there are a lot of mediocre coders, just like there are a lot of mediocre sys admins or plumbers or chefs. Putting formality around someone doesn't make him a better coder.
Does Slashdot have any advice for other questions to ask?
How much does the job pay?
How long is the job?
Is it time and materials, or fixed price?
What if the contract takes significantly longer than expected?
Will you give me a recommendation if I do a really good job?
What are you trying to get out of this question? Presumably you are going to add the factors together to determine if the legacy code is "good" or "bad". Then what? If it's kind of half-baked, in your estimation, you're going to turn down the gig? That's probably going to annoy the contracting company if you keep doing it. "What didn't you like about this job offer? The hourly rate was good, it was a short drive, it met these other criteria...". "Yeah, but the code wasn't up to my standards. Now, kindly hand me another glass of champagne and do try a bit harder next time, peon."
Good luck with that.
If you are going for a position where legacy code is a reality - I wouldn't hire you if you asked a question that depicted yourself to be either rather irritated by or incapable of dealing with legacy code. Positive attitude in interview, whine all you want when you get the job.
It really depends on whether the employer considers the code to be "bad", anyway. My guess is many would not fess up to the code being poor.
But by all means, you should ask all of those questions and go ahead and let it be known to your future employer that you don't want to touch any crusty old legacy code - it gives him more knowledge about you and makes it easier to make the correct hiring decision. It might hurt you, it could even help you, but no matter what, it will help you to land in the kind of job you want.
"I am almost never hired to build new software from scratch, so my work satisfaction tends to be proportionate to quality of the legacy code I have to work with." This statement makes absolutely no sense. Your job satisfaction should not be solely dictated by the amount and perceived quality of legacy code you are so "forced" to deal with. Working with existing code is a fact of life in this industry, get used to it. Instead of figuring out how to get around it by asking sneaky interview questions, learn to live with it. Also, why beat around the bush? Why not just ask the interviewer "How clean is your current codebase and how steep is the learning curve"? If they give you a sketchy answer... well I'll let you figure that out. I read this post and I think: "Maybe this guy chose the wrong career".
Oh code quality? Just from looking at the tags I thought this was a story about cod equality. Damn those herrings.
Bio questions? Ask me to start a Q&A journal. Computer analogies available for most topics!
Step 1: Avoid any and all circumstances where you have to modify shell scripts that dynamically build batch-processing scripts run through Peoplesoft SQR.
Step 2: There is no step 2.
The worse the code is, the more latitude you have to improve it. For most non-trivial projects, you should never replace something that's already there and working. The first instinct of the new programmer is that "this is horrible and I could do better writing from scratch." Sure, except that there are decades of business logic in that code, no requirements and things that look like side effects may actually be important. Assuming you ever get done, it will take much longer than incrementally improving the current system, take MUCH longer to deliver useful results and probably be less functional and as much of a mess as the existing system.
If instead you make a list of things that need to be improved about the current code base to make it less atrocious, prioritize it (I find by number of weekend phone calls any given feature's implementation would eliminate works great) and start working through them, you can make some serious quality changes in just two or three months. Improve error handling, refactor areas where code was cut-and-paste, set it up so a crash doesn't completely shut down production, and start organizing objects into sensible trees. By the time you're done you may have nearly completely rewritten the application, but kept it running while doing so and delivered immediate quality improvements to its users. It's every bit as much fun and challenging as writing new code.
I'm trying to teach myself to set people on fire with my mind... Is it hot in here?
I'm road worker and I often repairing spotty patches. The thing is, I'll only work on pristine roads. Makes sense, yes?
...and I make loads of money with it because it all works. You should focus your interview questions on the company's design and quality culture. I do appreciate clean, elegant, standards conforming codebases, but that's all academic exercise for the programmer. Users could care less as long as their software works the way the need/expect it to. Maintainability is important, but not as important as user experience. If the software does what users need it to do it will require *less* maintenance. Also, forget newer technologies because that just isn't important at all. Good projects use the *right* tool for the job despite current trends. Yeah, the stuff we have now is boatloads better than last decade's stuff, but you can still create useful software in FORTRAN or C. I stopped caring about code style when Sun first opened sourced Java. That codebase was barely readable but millions of people were happily using it. The fact is sausage tastes great, but the consumer *never* needs or wants to know how it's made. Ok, one step further here and some advice from a 25 year software trenches veteran: learn to appreciate and admire bad code. Learn to view it as a challenge presented to you so you have something to do to earn a living. Adversity is the avenue to opportunity.
Look, if you just want to be able to only write fresh stuff, you're useless. Your new code will become "legacy" code next month. Requirements are likely to change, or at least be refined. This is because project managers are not prescient and nobody ever really understands the real requirements until an alpha gets put into the hands of the end user.
It won't be long before you're going to have to go back and deal with the turds you yourself are crapping out. You might not think they're turds, but they are. That's because you're not prescient either. And if you spend too much of your energy striving for the most elegant, perfect code, then you're also constipated.
You're a better engineer if you can effectively reverse engineer other people's turds and polish them up a bit. If you can somehow find within yourself the ability to feel a bit of pride in addition to the disgust of dealing with other people's crappy code, you'll be happier in your lot.
You haven't made your bones as a programmer until you've spent five minutes cursing the idiocy of a programmer that came before you, whose crappy code you are having to fix, and then you look up the revision history to see who the offender is and discover that it was YOU.
Fun with Anagarams! LADS HOST, SHALT DOS. HAS DOLTS. AD SLOTHS, HATS SOLD. ASS HO, LTD.
Seriously...
System Operations is the art of keeping code running that should not be.
Ask them what is the crudiest and crustiest "module"/"unit"/"library" that is a part of their code. Then ask them to describe it and how they deal with it. If they claim there isn't one, then you know they are lying and head for the hills. If they can't think of which one is the worst then that spells trouble. Otherwise the answers to the question tell you a lot about the company. Also ask how they deal with regressions.
It could be that you suck, and people think you're not good enough to write stuff from scratch.
It could be that nobody in your organization writes stuff from scratch.
It could be that you're so good at fixing other people's crap code that you're too valuable to work on new stuff.
In any case, you need to either leave or start agitating.
You COULD ask to see their "Life Cycle Management" documentation folder(s)
IMHO... If they don't understand the question you're probably going to want more money...
One of my former students called me years back with the announcement that the brief (two hours or less) "Life Cycle Management" addendum I'd made to the Systems Development/CASE class I was teaching got him a promotion to a senior analyst position... That was the one area that none of the other candidates could discuss...
Apparently it wasn't something that everyone was teaching as part of the process of developing maintainable code and data structures...
My NOT being a full time programmer OR teacher might affected how strongly I've felt it necessary to include that subject.. but whenever I've had to go back to a former project... having a fully documented system has kept me from the necessity of reinventing the wheel...
.
Here's a novel idea. Write good quality code yourself, and stop job-hopping.
Are you taking jobs where you have to channel the previous developers and write code indistinguishable from them? do your jobs involve just transcribing someone else's crappy code char for char like some 14th century monk? Or, do you get to write code? I've supported plenty of legacy code. In all occasions that involves me, writing code. Optimizing, bug fixing, refactoring, adding new features (i don't know what else you could possibly do to legacy code) all involve writing code. So man up and write good code.
Does the Architect own a tanto? Has been required to use it?
The odds of that working are astronomically low. They probably don't want you personally that badly.
That's just an axiom of engineering. You can craft the most beautiful, standards-compliant, pattern-invoking code ever and the next engineer to come onboard will see it as a legacy, stove-pipe, monstrosity that needs to be re-written from the ground up. Of course, his rewrite will just repeat the cycle.
This request is like applying for a job being a plumber that doesn't work with shit. Sure, there are plumbers that only do new construction and never have to clean up a stinking mess of broken shit pipes.... Good luck landing such a gig.
... is to be an employee with a single-digit employee number in a start-up company. Beyond that, you will have to deal with the Big Ball of Mud. Deal with it.
I haven't been in the industry for ten years, or even near it, and I know that unless I'm being hired specifically to create something new I'm going to be working with existing code. And I've worked for some very, very small companies where the code I'm working on has been written by people who've been short on time and resources. It's looked like total butt. It's been slapped together with bubble gum and bailing wire, and I've done my best to leave it better than I found it for the poor sap who comes behind me. Unless you're being hired to create something new, you'll be working on something old. You're probably being hired to fix what they've already got. Why would this surprise you?
Seriously, if you don't want to work on existing code, look for jobs where you're being asked to develop something from scratch. If the code worked great in the first place they wouldn't be looking for someone to fix it, would they?
This unbiased moderation brought to you by the Porcine Aviation Group!
And programmers, in general, tend to earn more than the populace median. They also tend to put out more billionaires than almost any other sector that comes to mind.
You may as well have said, suck it up lawyers / doctors, remember, half of doctors / lawyers are below the mean.
I am John Hurt.
There's a decent chance he really is better than the previous guy. Just how do you propose that he "fix himself"? Sometimes there really is lously code. I'm always reminded of the story about the guy who left code where all the variable names were things like ass_function(), butt_fucking_variable(), stinking_anus; I'm not kidding. Totally non-descriptive, every permutation on posterior. Look me straight in the eye and tell me that ain't bad code, and that he should "just get used to it".
I'm also surprised nobody has gotten modded up with an answer that's obvious to me: In-place re-write, preferably in collaboration with several other programmers, according to best practices. Just go through, replace the worst functions, write plenty of tests, rinse, lather, repeat until you have a performant, robust and maintainable codebase.
For all intensive purposes, "whom" is no longer a word. That begs the question, "who cares"?
How would you feel about it if you had to drive over terrible sections of road just to get to the places you needed to patch, and there weren't enough other road workers of sufficient skill to ever make enough progress to patch the less critical sections that you nevertheless have to drive over every day?
If you have a choice, you might look for other opportunities, non?
Can you be Even More Awesome?!
...because this is like asking how to be a plumber without dealing with sewage.
Ask them how well they score on The Joel Test (see also this post with some suggested updates). This won't necessarily teach you about how much legacy code they have floating around, but it's a useful barometer. Part of what favorably impressed me about the place I am working now is that the VP I talked to (1) knew what it was, and (2) knew how they scored.
Ask how refactoring is viewed, if time is scheduled for specific cleanups of known "code rot"; if at least it is possible to include refactoring of relevant code as part of building new features. A too loose policy (which I've never seen but I suppose is possible) could be as bad as not budgeting for it at all; either can produce "legacy" quality code. Intelligent refactoring is part of the cost of maintenance (code "taxes", even).
Get into management.
>Any other ways to find out code quality beforehand?
Absolutely.
That's what code and test/process reviews are for (there's a lot of latitude in how people have done or attempted to do what they talk about in general terms during your interview).
When I'm thinking about working for a company with existing code I ask for a code walk through, test over view, and demonstration of how the build + test process works.
You do not want to work for anyone who refuses because either they have something to hide or have an ego about how much of their product is "special sauce" that might get bruised if you need to change things once working there.
One of the companies I did this with didn't believe in unit tests and I figured that they'd crater because they couldn't make releases on a fast and predictable schedule with acceptable quality for their customer base. The VCs rescinded their funding for that reason plus the long and unpredictable sales cycle that goes with enterprise appliances which also had me running away.
This isn't fool proof - one company I worked for had good process but abandoned it in a panic when they realized they'd picked the wrong market and needed to pivot. Discussing the false dichotomy of quality and delivery speed (you can have both or neither) with anecdotal stories, delivering much more reliable features with out bugs leading to multiple release candidates built with good process, and having people read things like _The Clean Coder_ didn't help.
In many cases "buy" where buy can mean leveraging free software is the right answer not "build" for things that are not core to product value. You may still find yourself changing and cursing open source.
I also try to avoid that by joining new projects (not fool proof - projects get cancelled when companies pivot, companies often re-organize people to deal with tactical issues, some companies declare your product "finished" and ship it over seas for maintenance after which you join a new in-progress project, etc.) and/or new companies between series A and product design (surprisingly not fool proof - some smart people do bad things when direct to by bad managers. Two of my favorite CEO quotes are "Test code doesn't ship to customers" and "we'll add quality later." That had a lot to do with the resulting crater.)
Startups = work on the new, reinventing a wheel or ten. Established companies = work on the established, sometimes no creation, buying products instead of creating them.
Certainly don't become trapped with a dying language, but do not arbitrarily rule out working with legacy code. Think of it as a challenge instead:
1) You always learn something even if it's negative (don't do that!!!)
2) You gain insight into another's thought process. Sometimes that's scary, but again, you learn something - a new perspective, perhaps.
3) Really bad code can let you pull off the impossible - improving performance, reducing resource utilization, etc. You can become the "go to" person, with the job security and good performance evals that come with it.
Give it a shot before turning up your nose.
The contest for ages has been to rescue liberty from the grasp of executive power. -- Daniel Webster
I have for well over a decade worked at maintaining legacy code, but I always relished finding the absolute crap applications and redoing them from scratch.
So I am kind of puzzled about the question. What kind of coder avoids jumping in and making something fresh and new and challenging his or her skills to not only replace something craptastic, but make something that his or her co-workers look at and go "Wow"?
_ _ _ Go for the eyes Boo! GO FOR THE EYES!
Ask what language the project was written in.
If they say one specific language, you might be good. And don't count "helper" languages - a PHP app that uses SQL counts as just one language for these purposes.
If they mention a few, or one and a few dashes of something else (C with a bit of assembler, PHP with a Python script for one weird bit, C# with a few files of VB.NET), you're possibly good as well.
If they list a large number of languages for one project, run.
There's a project I'm thankfully not fully attached to at work. Long story short, we're a small-ish company that got contracted to rewrite and extend this old product, as the original developers were either fired, or sued, then fired. I only work on the "extend" part, turning what was once a module to integrate into other software into a full suite, but I've heard stories from the guys handling the rewrite. The original devs basically used it as a training ground - any time they wanted to learn a new language, they'd take some feature request and implement it in the new language. So the entire thing is basically written "by beginners", since they never really figured out any of the languages. And there's a lot - a mix of PHP4 and PHP5, some Python, some Perl, some C modules that no longer have source, and I think a few others.
And these are for large chunks. The rewrite actually doesn't stick to one language either, but 99.99% of it is PHP (there's one ten-line Python script to act as a proxy for one thing, and a Java tool that was *supposed* to be just for internal load testing, but the higher-ups adopted it for marketing demos since we apparently beat our nearest competitor by two orders of magnitude).
So yeah. If you see a single application where more than one language is used for more than, say, ten files, you should be wary.
Now, it's entirely possible to have a completely horrendous codebase using a single language, but that's been covered by others.
The trick is to stay around long enough to reap the benefits of all your good refactoring work. If the software gets better and better, that should show up in whatever metrics management uses (downtime, customer satisfaction, whatever), and then they should pay you even more.
So the trick isn't to look at the quality of the code at the potential job. The trick is to figure out if, at some point, that quality comes under your control, and if you will have a nice work environment and be rewarded commensurately.
Uhm, some of the headers had opening comments with dates that would require a negative value unix time...
http://web.opennet.ru/docs/FAQ/network/Mail/mmdf-faq.html
-- A change is as good as a reboot.
Don't whine.
Don't use TDD.
Don't assume use of modern language features yield better code.
http://xkcd.com/610/
Changing career is the only real suggestion I can make. You're always going to run in to terrible code unless you only work on greenfield projects; and the only difference then is how long it takes for that code to become a terrible nightmare with all traces of design lost to the ages.
Oh and run away from any company that uses the phrase "agile development" unless they can give you a satisfactory definition. In my experience a lot of people use the phrase when what they actually mean is "making shit up as you go along".
Yeah, I had a sig once; I got bored of it.
I do this by not working at all.
People whine about this recent bad economy, but for some of us, we can't find a job after graduation since we graduated right after the dot com bust. Only thing I can do is continually try and start home businesses. Here is an example of a game I wrote. I think it showcases I have competency to code effectively. There are a great many people today who are talented, skilled and hard workers, but just due to the economy, there is no place for them to work.
God spoke to me
Have you worked at all in any capacity respecting intellectual property?
About the only thing missing from your 'game' is:
http://www.hark.com/clips/bftljkyxzz-needs-food-badly
Ask them how they test the application. Because you cannot change it easily if you worry about breaking stuff.
nosig today
Work minimum wage for the rest of your life, and quit your bitching. After all, being completely willing to take minimum wage for the rest of your life will ensure that you will never be priced out of the market. Quit your bitching, and so long as you get paid, work for it. I am willing to do anything for minimum wage. I highly doubt I will ever even make $25,000 per year. Do I have goals beyond keeping myself and small family alive? Nope. I will likely die at work on the clock. Dreams are for people who have too much time on their hands. If you have time to "dream", you could be using that time to work and make money. Get a grip on reality, before reality gets a grip on you. "Dreaming" is for college students who have no realistic expectations out of life, and think everything will be handed to them just for breathing. Guess what? You don't get "extra credit" for breathing. Now keep up with the market, and realize what you are worth. Absolutely nothing. You are easily replaceable.
Get your free Dropbox account with 2 GB Free storage!
I've worked with awful code many times. Early in my career it drove me crazy. After doing it a lot, I'm used to it. Frankly, a lot of the jobs maintaining the crap are easy jobs, and there is a certain skill and satisfaction in dealing with it. Plus, nobody else wants to do it, so you have a job for life and can name your price. My suggestion is don't avoid it, learn to love it. Embrace it.
You're not likely to ever avoid any and all legacy code. If you can have some of your own code, you should probably consider yourself blessed.
Distinguish between code that's still "good enough" to maintain and code that's such a horrible mess that you can't live with it. Invariably, legacy systems are poorly documented, but if you can more or less find your way around them, you'll be able to maintain them.
Otherwise, the most effective way I've found around legacy code is to replace it with my own. For small systems, this is fairly straightforward, as in principle you will often be able to re-build them from scratch in a short amount of time (be prepared to put in the work though!) For larger systems, you'll have tackle it a module at a time. Then of course there are systems where you cry out, "Module? What do you mean module?". If a system doesn't seem to have any structure, propose one! Describe the issues with the existing system. Explain to management why they're bad for the bottom line (maintenance costs are higher in a badly designed system). Chances are, you'll get the green light to replace it with something cheaper, if it's worth the investment. Be prepared however to do a fair bit of documenting. If you can't explain to yourself what the existing system does, chances are you'll overlook subtleties when implementing a new one. You may well find out that once you've documented the existing system far enough, it's at least maintainable (see above: "good enough").
For what it's worth, it helps to have some sort of toolbox that allows you to quickly whip up small systems. In my experience, companies are often willing to replace bad software if it takes up to a few weeks, but not if it takes months.
Visit http://ringbreak.dnd.utwente.nl/~mrjb/growingbettersoftware to download your free copy of the book
Proportional to the quality.
Except it's bollocks, because neither "variable" is quantifiable in any physical or mathematical sense, so applying such precision is so exponentially retarded it literally makes me laugh my tits off.
Confucius say, "Find worm in apple - bad. Find half a worm - worse."
We all want to play with the cool stuff. But to be honest you will absolutely have to work with legacy.
A really good designer/programmer/architect can not only work with the legacy but can actually design/implement a path where the legacy is deprecated out of existence. A bad programmer/designer/architect ignores it and lets it fester. The guys that get the big bucks consistently are the ones that move things forward. The ones that only will work with the cool tools/toys tend to bounce jobs and provide little over all value.
So in essence. SUCK IT UP.
I am once again stuck working with crap legacy code that is even crappier because all the installed versions for different clients are custom tailored (read: totally different meaning you are support 12 application instead of one where they all share the same bugs but can't be fixed with the same patch).
And I have started to notice something, and shot down a recruiters suggestion just a few minutes ago because of it. If a place only has seniors, it means the code is a mess. Trivial changes should be done by juniors if trivial changes can't be done by juniors, it means the code is a mess. Usually a mess created by making fantastic code that really showed off a coders skills but in the end is just spaghetti code were to much happens in one place for anybody to easily read the code and find the place that a fix should go.
If you played Transport Tycoon, you can see if you can write non-nightmare code. Did you create a interconnected network of trains where you tried to get the max number of trains to run on the least amount of track and dreamed of a sequel that would give you better router options?
Or did you just create nice simple separate routes with just 2 stations and at most a dual track to create a circular loop so your trains never got lost or stuck?
One is the code genius solution, the other creates code that is easily maintained. Go and play the game, create both type of networks, then alter a route. In the first, you will have to deal with countless problems as all your train routes collapse and first directly affected trains get lost and then become stuck creating troubles for your entire network. Just like in complex rail networks in real life like in Holland.
But on the kind of network you computer opponent builds with just 2 stations and trains running between them, you can easily dig up a route and redesign it and the rest of your trains continue to run their separate routes.
Juniors often lack the ability to deal with code where a tiny change here might cause something to break there. That is what seniors are supposed to be good at.
Consequently, if a company only employees seniors, they got spaghetti code.
I have been working on a wiki page to get my brainfart that MS original trouble with getting MS Office out the door, called development hell, has bastard brother in maintenance hell, where you are stuck repainting the preverbial bridge but the previous painters left such a mess AND are still doing it you never even get to painting but once you cleared the bridge of the mess the previous painters left behind, they started leaving a mess at the other end again. And if the bridge never even gets started painting, you can forget about structural maintenance.
At one company, disastrous code had been upgraded to a condition described by the developers as "stable". Stable as in how doctors use it to describe a patient in emergency care which really means "patient can now be moved for serious surgery without it killing with absolute certainty". Management thought stable meant "perfect health". It wasn't. Management planned a host of new features, we were to busy trying to keep it from falling apart on the spot.
Maintenance hell is real and it happens when your code has become so bad, that SCRUM is impossible because SCRUM MANDATES that you have your bugs under control. How can you after all estimate a project when any chance you make is going to open most certainly a can of worms but you have no idea how big or just how lethal the worms are. Maintenance hell is when only the developers who made the dev in the first place can not quite maintain it and then they leave and any new developers you hire burn out in six months and you start to accept that people only will become productive after six months studying the code.
So, questions to ask: Spread of Junior/Medior/Senior developers and... why are their existing developers leaving. Usually you can already get pretty good idea of the company by going into the history on job boards. Every 6 months they are looking to hire a senior (In holland it is standard to start with a 6 month contract)... maintenance hell, they are replacing their burned out sucker eh, developer.
MMO Quests are like orgasms:
You may solo them, I prefer them in a group.
Offer to sign an NDA, but don't ever take over someone else's codebase without making sure you see the code.
Employers: Don't hire anybody who offers to take over someone else's codebase without having seen the code.
This is a complete no-brainer.
-- 'The' Lord and Master Bitman On High, Master Of All
Maintenance tasks are a bit harder to outsource than greenfield development.
Not to mention the fact that it takes a different set of very useful skills to maintain and debug code, especially poor quality code. There are serious benefits to seeing what's good and bad, what works and doesn't; how to comprehend other people's code (yes, it's a lot harder to read code than write it); how to debug intelligently, and how to profile code. These skills are hardly ever taught, and have to be learnt on the job.
Don't begrudge being 'stuck on maintenance': it takes a lot more skill to read and rework old, crappy code, than it is to write new greenfield code. Just make sure that you're given enough time, resources and "creative freedom" to introduce beneficial changes, like unit test coverage and continuous interegration (I won't work for anybody who "doesn't have time to write unit tests", because it betrays a dangerous level of cluelessness.)
I might be in the minority, but I've learned to love the challenge of taming a beast of a code base.
Coming in and helping out people who don't have *anything* in place and slowly adding order has a satisfaction level all of its own.
Building out a test suite as we document business logic and then planning a refactoring can be rewarding too!
-- Trinity in high heels carrying a whip: The donimatrix - there is no spoonerism
I agree that bad code is the norm. My recent experience was a large Perl codebase, belonging to the merger of about four different companies that did the same thing but [of course] had different business processes. The code was in the gigbyte range with tons of templates and about four foreign lanugage versions.
However the code base covered many corner cases in the business model, pricing and marketing and [in the main] worked.
Thirty odd years of experience has shown me that a re-write of something like this is usually a disaster, I agree with Joel: http://www.joelonsoftware.com/articles/fog0000000069.html
The least-worst way is rolling reviews through sections of the system and a very comprehensive set of regression tests. But the point is that, at some stage, one will have to engage with 'bad code that works', it's the way of the world.
On y va, qui mal y pense!
The use of modern tech does not imply better code, but it certainly helps your work environment. A company that is quick to adopt new technology (e.g. Update to new language versions) has a better possibility than a company that doesn't. Make sure you talk to the guys involved with the technology. Interviews and screenings with recruiters are quick affairs, save your questions until you meet real developers. If the company doesn't have the actual developers and team leaders doing interviews, that is not a good sign. Third, make sure you find out how fast the crew is being replaced. A team of ten should have at least a few that have been there virtually forever, and you don't want to join that team if it has recruited 20 developers over the last 5 years. This is the most important thing: you want the same as every other developer out there. So a company where people work 1-2 years either has a technology problem or a serious pay/environment/cultural problem. Either way, you don't want it. Ask how many have left the last few years, and try to find out why. If you can't get this information, leave.
If you're working with other people's crappy code you're just a programmer. Get over yourself.
To have a right to do a thing is not at all the same as to be right in doing it
The first thing I do when ever I sit down to work on old code that I haven't developed is to comment every ( or almost every ) line of code. Once I fill in all the comments I can get a much better sense of what the developer was trying to do and in some cases fix those awful blocks that almost stun the mind. The second thing I do is upload the code to a SCM system like GIT and then fork it so I'm always working off a separate branch. Beyond that I just usually need a lot of coffee, a few good cigars and loud music because lets face it 70%+ of old code is beyond the state of crap.
The two things I ask about are a design document and an automated QA system.
Don Knuth's Literate Programming is the very best way to write a design document, but even much less than that is better than nothing. The worst case is having nothing but uncommented code. I once had a programmer tell me that he didn't need to comment his code: the names of the variables provided enough information. He was coding in Macro-10, a language that limited variable names to six characters.
The automated QA system is crucial for maintenance. You need a test for every feature described in the documentation, plus one for every bug fixed, to make sure it doesn't come back. The QA system must be automated or management will insist you skip running it because a bug fix has to ship "right now", and you don't have two days to run the manual tests. Having a QA system that can be run after each build is so important that it should be the first thing you write when taking over legacy code. If you aren't allowed to write it because fixing bugs or adding features is more important, pass on the project.
When I started programming I didn't have to deal with legacy code, even though I was at a large university. That was because when I started programming there was no legacy code: we wrote everything ourselves. A friend of mine wrote the original recursive binary to decimal conversion subroutine for the DEC PDP-1, and was astonished when it worked the first time. The world has moved on, however, and the situation I was in no longer exists.
Don't list any old legacy languages on your resume. Only list the latest ones that you actually know and want to work with. You'll get fewer offers, but what you do get should be higher quality.
now we need to go OSS in diesel cars
Fixed it for you. Seriously though, carry on being a prima donna. It makes finding work that much easier for me.
Legacy systems ran for a long time (normally). That's why you get the job. The shit has to be ported to a new platform, features have to be added etc. Legacy systems are long lived or long living systems, therefore a lot of people laid their hands on it, which results in crossover styles in programming which results in bad code. Therefore:
* The older the code base, the worse the code
* The higher number of transitions (migrations/feature changes) of a code base, the worse the code
* The less real documentation exists, the worse the code
* The worse the programming language, the worse the code
C,C++,Perl,Fortran 77, Cobol, Fortran 4, PL/1, Assembler => bad, worse, unmaintainable, even more unmaintainable, are you kidding me, we hit mars period, it talks back and WTF.
So you can conclude a formula from that: (1/code_age)*(1/(transition_counts+1))*documentation_quality*programming_language where documentation quality is defined as 0 no or bad documentation and 1 perfect documentation and programming language is defined as WTF/assembler=0 and C=0.5 (Languages such as Erlang, Haskell, Scala, Java, C# get higher marks).
A value 0 zero indicates great mess, while 1 indicates nothing to worry about. While most legacy systems are implement in the range between bad and WTF, you will never get more than 0.5 out of it. As documentation is even in new projects not really existent. They produce a lot of paper, but there is nothing in it. So you can say you get not more than 0.5 for documentation quality. As most projects are more than 10 years old, you get 0.1 for age and at least 2 transitions so 0.25. So my best value would be 0.5*0.5*0.1*0.25 = 0.00625 or the quality is below 1%. You normally get an F (or 5/6) if you are below 50%. So it is easy to conclude:
All legacy systems suck. Ah and yes, and you should get used to it.
Most recently I had the opportunity to serve as the sole Android developer in charge of some pretty terrible existing code. Since I was the only Android developer and, indeed, the only person at the (small) company with any knowledge of Android whatsoever (i.e. there was very little oversight of my activities and, since the existing app was so terrible, very low expectations), I just rewrote all the really abysmal parts from scratch. Taking a slow, buggy, visually inconsistent app and making it fast, robust and visually consistent was fairly gratifying.
I make a damn good living from working on legacy code. Bad legacy code. Really awful legacy code that no one else will touch. I was hired at my current job 5 years ago specifically because I am very skilled at taking very bad code and either completely rewriting it, or picking at it to find the parts that need to be fixed and fix them. I've spent the last 5 years taking C++ code written by a librarian (yes .. you read that correctly) and rewriting it in Java (bosses requirement, not mine) to make it run faster, rarely abort, and actually produce meaningful messages if it does abort. Code that we don't even know if the current source code matches what is in production, so we can't really even make changes to it. We rewrite it, then parallel test to make sure. (There were many reasons to rewrite it, and it wasn't my decision. Although I agreed.)
.. the lazy ones that are really just not skilled enough to be able to do it.
.. my yearly wage has 6 digits to the left of the decimal point, and the first two aren't zero.)
It takes a lot of skill to be able to read code that is 10 years old or more, has no documentation, and is so full of unnecessary convolutions and nonsensical algorithms and make sense of it. There are a lot of companies out there that are tired of hiring programmers who later on won't work on something because it's too confusing or too hard. You know
Sure, I love to work on new stuff. But instead of whining about how hard and difficult it is, accept the challenge and wear it proudly, knowing that a significant number of your peers couldn't do the task.
And the best part of working on old stuff?? It's really difficult, so it takes time. And since no one else is working on it, they have to take your word for how long it takes to get it done. Now, I don't sit around all day in slippers sipping coffee and writing a few lines here and there. But I also don't put in 60 hour work weeks. And I'm probably getting paid more than a lot of you. (Hint
I rarely read replies, it's my opinion and if you thought about your opinion a little more, I'm OK with that.
TDD is great but it isn't the solution, new technologies aren't really new, a lot can also be done with older.. The biggest problem today IMHO is that the so called new technologies run like crap on modernday computers, you have to have a highend to get the same performance as with the old technologies, well that says to me that new technologies just plain suck and are especially for lazy developers.. Computers get faster but applications get slower, hmmm, that's wrong IMHO.. And remember, it's not like 'new' code is better than legacycode, I've seen 'new' code which is much MUCH worse as old legacycode.. especially since it seems a lot of people tend to forget to comment their code.. And please, don't give me that crap 'good code is easily read' as 'crap code is also easily read' because 'good code' is only 'good code' in the eye of the beholder..
I made millions off that...
I'd be interested if the OP had a feel for whether adherence to certain practices does, in fact, result in a better codebase. Personally, I'm skeptical that they do, even though I think that some of them are probably Good Things to Do, simply because they might help.
Crappy code can keep you very profitably employed for a very long time. After all, the object of the game is to make as much money as possible in as short a time as possible, so that you can retire early. This strategy worked very nicely for me. You just have to learn to stop hating your job and employer.