Slashdot Mirror


Real World Code Sucks

An anonymous reader tips an article at El Reg about the disparity between the code you learn at school and the code you see at work. Quoting: "There is a kind of cognitive dissonance in most people who've moved from the academic study of computer science to a job as a real-world software developer. The conflict lies in the fact that, whereas nearly every sample program in every textbook is a perfect and well-thought-out specimen, virtually no software out in the wild is, and this is rarely acknowledged. To be precise: a tremendous amount of source code written for real applications is not merely less perfect than the simple examples seen in school — it's outright terrible by any number of measures."

74 of 292 comments (clear)

  1. must read: "worse is better" by Polo · · Score: 5, Interesting

    It might be interesting to read The Rise of "Worse is Better"

    1. Re:must read: "worse is better" by firewrought · · Score: 4, Insightful

      It might be interesting to read The Rise of "Worse is Better"

      That's a great article for high-brow programmers who want to triple-plus-abstract and design-pattern everything. You know... the folks who Joel Spolsky calls "architects astronauts". However, notice that this article is readable and thoughtfully characterizes the two coding styles it trying to differentiate. Fundamentally, this person knows their craft.

      This is unlike some of my coworkers, who still embedd SQL straight into their GUI's. (I know of one of our apps where all the methods have the same 30+ parameters being slopped around [to represent a row from table X] because the original dev team couldn't be bothered to create a class called "X" to represent the concept of X and so pass around 1 reference.)

      These people aren't heroic real-world veterans who sagely ignore the pretentious chatterings of academics... they're simply folks who don't understand how to express themselves clearly in code, much less the runtime environment, compilation process, or other fundamentals of the basic tools they've worked with for the past ~5 years.

      --
      -1, Too Many Layers Of Abstraction
    2. Re:must read: "worse is better" by pixelpusher220 · · Score: 5, Insightful
      Summarized as follows:

      "In theory there's no difference between theory and reality....in reality it's the other way around"

      Seriously, real world code is by definition 'real world' and doesn't live by the theoretical pillars of design. It has to deal with actual deadlines, finite resources and of course office politics.

      --
      People in cars cause accidents....accidents in cars cause people :-D
    3. Re:must read: "worse is better" by icebike · · Score: 5, Insightful

      Summarized as follows:

      "In theory there's no difference between theory and reality....in reality it's the other way around"

      Seriously, real world code is by definition 'real world' and doesn't live by the theoretical pillars of design. It has to deal with actual deadlines, finite resources and of course office politics.

      Exactly.
      Where the professor can take 6 months to prepare a small simplistic demo application custom tailored to demonstrate his (pet) coding methods and design standards, in the real world you have to get things done, not in 6 months, not in 6 weeks, and seldom in 6 days. You might have 6 hours on a good day.

      Does too much of this quick hacks find its way into production?
      Absolutely.
      Do bad 2x4s find their way into house construction? Of course.

      But corporate world code runs every single day, not twice a semester. Its "good enough".
      And if it starts to fail it get rewritten, or patched. The truth of the matter is that corporate
      systems are long lived, and few if any are fully understood by the current staff, because the guy who wrote it moved on 8 years ago.
      And Yet, it gets the job done day after day, year in and year out, because people watch it and know what to expect.

      Do houses fall down because of bad 2x4s? Virtually never. Maybe after years of
      remodeling, rewiring, re-plumbing, the place will burn down, but there is usually
      a recent idiot involved, rather than the original builder.

      We build things "good enough" in this world. Not Perfect.

      --
      Sig Battery depleted. Reverting to safe mode.
    4. Re:must read: "worse is better" by Anonymous Coward · · Score: 4, Insightful

      It's not even that. These academic examples are small and trivial. They don't have to adapt or integrate with other systems. They are toy examples and it's really damn easy to make those 'perfect.' How many god damn quick sort examples in Haskell convert to anything in the really real world?

    5. Re:must read: "worse is better" by kestasjk · · Score: 4, Insightful

      To be honest more often than not poor code will just be about getting something out there with the minimum work, rather than because of deadlines. The code is usually boring, and/or it's already poor, so few will come along and sort it out to make things easier down the line (especially when even the best rewrites are usually more risky than a minor hack to a hacked up system, in the short term).

      --
      // MD_Update(&m,buf,j);
    6. Re:must read: "worse is better" by pixelpusher220 · · Score: 4, Interesting

      academic examples aren't bad in and of themselves. They are specifically teaching you how to do 'X'.

      In production you have to know how to apply X, Y, Z, B, E, and G. But you don't start by trying to learn all of them at once. You learn simplistic examples that hopefully teach you the theories and best concepts for 'X'.

      --
      People in cars cause accidents....accidents in cars cause people :-D
    7. Re:must read: "worse is better" by Tagged_84 · · Score: 3, Interesting

      I was tasked with getting a multi-user database and customized front-end up and running by the time the field staff were ready in a couple weeks. I ended up having to patch and fix it as it was being used for weeks before requesting that I then start on another one.

      In their almighty wisdom they thought I wasn't doing as great a job and replaced me with some kid straight out of university who had never programmed in his life. The entire data team crashed, stopped accepting data and had a huge backlog, cost tens of thousands of dollars in lost productivity and project holdups. It was my state government btw and it taught me that my imagination is lacking when it comes to government waste and abuse.

    8. Re:must read: "worse is better" by TheLink · · Score: 4, Insightful

      True but I haven't seen much academic example code that has plenty of logging in them.

      In the real world much good code is filled with exception handling and logs. Because for almost anything that you try or call something wrong/else could happen or something could send you a SIGTERM or similar. You'd leave out the logging in the high performance processing loops, but in the real world those often are only a very small part of the code.

      So it's not just most real world code that sucks in the real world, most academic style code would also suck too. ;)

      Yes there are different logging systems, but you can pick one or two as examples - after all there are also many computer programming languages and most academic courses still teach at least one programming language.

      Anyway the story also reminds me of: http://www.ariel.com.au/jokes/The_Evolution_of_a_Programmer.html ;)

      --
    9. Re:must read: "worse is better" by luis_a_espinal · · Score: 2

      Summarized as follows:

      "In theory there's no difference between theory and reality....in reality it's the other way around"

      Seriously, real world code is by definition 'real world' and doesn't live by the theoretical pillars of design. It has to deal with actual deadlines, finite resources and of course office politics.

      True that, but none of those facts intrinsically preclude people from laying out some structure into the code they churn.

      Proper indentation, sticking to the object/verb pattern of naming objects (or data types) and methods (or functions), closing the resources you open, programming defensively (instead of nillie willie happy go lucky programming), keeping your functions small. All those things good developers can use and deploy as they put out fires in the real world and all the challenges therein.

      A good developer will churn code of some quality under strenuous conditions because he automatically thinks about a certain type of attributes that must be present in code. Any kludge that he/she might produced is done from a position of knowledge, as an intelligent compromise done to meet a challenge.

      OTH, a shitty code monkey will crap out a fetid turd even in the presence of ample resources and fixed requirements.

      So, no, real software might run in the real world, but the real world does not produce shitty code. Shitty developers do.

    10. Re:must read: "worse is better" by dbIII · · Score: 2

      In a lot of cases the shit code is also "toy examples", especially where somebody's personal nasty little flat file storage system becomes some sort of inventory "database" for a department.

    11. Re:must read: "worse is better" by drinkypoo · · Score: 2

      Do houses fall down because of bad 2x4s? Virtually never

      Houses are engineered structures. We have building codes which demand so many studs per so many feet because the math (or experimental home building, often experimenting with the buyer's money) has been done to figure out that only a vanishingly small percentage of homes will experience a lumber-related failure if you use at least this much lumber, even though modern lumber is crap in every way except for being milled smooth. But choosing the wrong operator in the wrong function can result in your program producing invalid output every time you run it. If you eliminated almost any one 2x4 from the design of a decently-designed house, just forgot to install it entirely, it would not substantially affect the function of the house whatsoever. Only a few around doorjambs and such would really be missed. (Or, of course, the top or bottom of any frame...)

      Most software is apparently not "engineered" and even where it is it doesn't happen in the same sense as a house because it's a very different realm. Unless it's actually fully proven, you can't be engineering it in the same sense you do something here in meatspace.

      --
      "You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
    12. Re:must read: "worse is better" by Tagged_84 · · Score: 2

      Of course I did, the fact they thought someone who never programmed could pick it up within a week really highlights how incompetent they were.

    13. Re:must read: "worse is better" by TheLink · · Score: 3, Interesting

      Yeah I still have no idea how to do logging well.

      But what I like to do when performance is not an issue is to log everything (DEBUG etc) into a context ring buffer. Then normally only log messages above the configured log threshold will appear in the logs (e.g. INFO, NOTICE, WARNING). The DEBUG stuff won't appear. BUT if a log message above a log the context threshold occurs (e.g. ERROR, CRIT) the contents of the context buffer is logged followed by the actual triggering log. This way I don't have to turn debugging on. It can always be on BUT I don't have my logs full of the debug level logs unless "stuff happens".

      This context logging stuff is bad for performance, but so far it's not a problem for the stuff I do (and can be turned off). It does make it easier to figure out what happened while creating less DEBUG noise.

      As part of my log messages I also have hashes and dots, e.g.:
      DEBUG = one hash = #........
      INFO = ##......
      NOTICE = ###.....

      This way I can easily "grep" log files for logs above a particular threshold. If you're Google or Facebook scale you'll have to do things a bit differently because there'll be zillions of logs, you can't have half a million machines send logs to one log server ;). So you'd need a way to summarize logs.

      It might also be nice if the CS lecturers spend some time discussing the merits of different exception handling approaches in various scenarios. Instead of just stuff like this: http://www.cs.auckland.ac.nz/compsci105s2c/lectures/adriana/Lecture06.pdf

      Doesn't need to be as detailed and extensive as this: http://www.amazon.com/Advances-Exception-Handling-Techniques-Computer/dp/3540419527

      Just some basics that might open up student eyes to how things work in the real world and more importantly how things could fail, and how one might deal with them.

      FWIW I didn't do CS. I did EE. So maybe this stuff is actually covered in some CS courses. I doubt it was covered in my colleagues CS courses though ;).

      --
  2. Captain Obvious? by Anonymous Coward · · Score: 5, Insightful

    This just in: real world a lot harder than school.

    Gee, thanks Slashdot!

    1. Re:Captain Obvious? by K.+S.+Kyosuke · · Score: 5, Funny

      The first thought that occurred to me is the equivalent situation in literature: People go to school, read and learn from Shakespeare, Austen, Melville, Twain, Hemingway, Faulkner, Tolkien...and then they go out and write Twilight and Hunger Games. I guess some people simply aren't cut for it?

      --
      Ezekiel 23:20
    2. Re:Captain Obvious? by Smallpond · · Score: 2

      This just in: real world a lot harder than school.

      Gee, thanks Slashdot!

      The reason is pretty obvious. The 25-line program you write for a school assignment is not the same as the 5000 lines you are writing to implement a set of vague business requirements.

    3. Re:Captain Obvious? by ShanghaiBill · · Score: 5, Insightful

      The 25-line program you write for a school assignment is not the same as the 5000 lines you are writing to implement a set of vague business requirements.

      Some of those 25-line programs are not so good either. If you really think students write good code, get a job as a TA and grade some assignments.

    4. Re:Captain Obvious? by Penguinisto · · Score: 5, Interesting

      It's even worse than that.

      These folks learn the classics, but then go out and are forced to make a living by making new editions of Twilight, Hunger Games, etc. As a bonus, they're not allowed (by edict and budget) to change more than 25% of the nouns (in aggregate, not as categories).

      --
      Quo usque tandem abutere, Nimbus, patientia nostra?
    5. Re:Captain Obvious? by Phrogman · · Score: 5, Insightful

      Then in school they should be recreating the actual real world experience, you know:
      * a representative from the "Business" comes to you with a vague concept of what they want, mostly consisting of "Something like X" but more like "Y" with some of the features of "Z" (3 completely different things that have no apparent relationship to each other). After a few days of meetings you determine that what the person wants is based more on the colors used and the layout being pretty to them and not at all on the features or functionality.
      * You then seek out a group of various people who actually know what might be required, and grill them to try to get an idea of the features and functionality required. From this you create an initial design document.
      * You run the design document that describes what you think are the features and functionality past the people above who all agree you are on the right track. You add more details and they all agree its perfect. Mostly they don't actually understand what you are talking about but they nod their heads sagely and agree because they don't want to look incompetent.
      * You begin coding (or possibly get together with a team and fight over things for a few days/weeks/months) and get a prototype built. You show it to those you have spoken with and again its on the right track.
      * You code up the first version. You reveal it to people and its "great".
      * Then the people start filtering in with design "suggestions" that mean massive changes to what has been written and done, possibly shifting the entire project in a different direction. These conflict with each other and trying to find the middle ground occupies as much of your time as actually trying to write anything.
      * The marketing people come into the picture and it turns out that *they* are the ones that really have the authority to make the design decisions, not the people who you originally talked to, but as an added bonus the marketing people don't have the slightest clue about the required features or functionality - just what they think they can sell to customers. Getting their salable features shoe-horned into the program becomes your top priority now.
      * The program also has to look "pretty" so the art department enters the picture and they demand massive changes so that the layout is much nicer and easier for them to do, minimizing their workload as much as possible because they are completely overworked and under-budgeted. You meet with artists in rooms that are completely dark and stare at photoshop images that are renderings of what they see the program looking like. It bears no resemblance to what you have been working on and they have made massive changes to everything renaming all the menu entries etc. It is however pretty, or rather the 3 different versions of it are pretty, and you have to wait until marketing determines which one is the best.
      * now you are way off schedule because of all the monkeys who are making changes based on whats the most important thing from their perspective.
      * Eventually its all nailed down and you hurriedly code the new first version up as fast as possible because of pressure from above to be "done this thing already".
      * At the last moment when its done, it gets cancelled to be replaced by some other project which is higher priority, or they announce it must be entirely recoded in a different language/script.

      Shove that student into this environment. Get people to play the various roles that are about as knowledgeable as people you will encounter in the corporate environment - which is to say find the most qualified idiots you can and put them in the roles.

       

      --
      "The first time I got drunk, I got married. The second time I bought a chimpanzee, after that I stayed sober" Arian Seid
    6. Re:Captain Obvious? by Penguinisto · · Score: 2

      ...to say nothing of the fact that instead of writing a program from scratch, you're forced to maintain others' programs instead, or to add what you write to existing (fundamentally crap, poorly-maintained) code.

      Yay?

      --
      Quo usque tandem abutere, Nimbus, patientia nostra?
    7. Re:Captain Obvious? by Macman408 · · Score: 3, Interesting

      This, and even the *book* is wrong half the time. Given the pressure to come out with a "new edition" every couple of years that many publishers and authors face, they re-write many parts of the books, including examples and problems. Often, it's clear that what the author wrote hasn't even been compiled before, as there are glaring syntax errors. (Obviously, some books are better at this than others.)

      Most of the people I work with produce much better-looking code than a college student. Interns come in periodically and help prove that point; they write for ease of coding, not ease of reading or maintenance or reuse or anything nice like that. The code from more experienced people is by no means perfect, but they've at least seen both good examples and bad examples when they have to touch somebody else's code, and they tend to pick up a few of the good habits while dropping a few of the bad ones.

    8. Re:Captain Obvious? by clemenstimpler · · Score: 2

      My questions are not tainted by real world experiences, so feel free to enlighten me. 1. If it is the marketing people who have the final say, why aren't they part of the process from the beginning? 2. If design people can throw in fundamental changes to UI, why are they the last to be asked? In sum: Is this just mismanagement or is there some fundamental truth about real world development that escapes me somehow?

    9. Re:Captain Obvious? by jimshatt · · Score: 4, Interesting

      Reminded me of a comic by the oatmeal: http://theoatmeal.com/comics/design_hell

    10. Re:Captain Obvious? by greg1104 · · Score: 2

      Even your longer example doesn't do enough justice to how much of this problem is management based. This article was terribly biased toward blaming programmers for these issues. Schedule pressure to release on a date no matter what causes more bugs than anything else. Having some sort of deadline is necessary; if left on their own, programmers like to tinker with stuff forever. But you can only compress things so much, and management requirements are often impossible to hit. The standard example here is the Fred Brooks one of "9 women can't make a baby in 1 month".

      If companies valued their programmers doing high quality coding, I'd make a living teaching classes in things like error handling paranoia. But they don't. The developers are just an expense to be reduced, and there's almost no business environment that values high quality software correctly.

    11. Re:Captain Obvious? by Mandatory+Default · · Score: 2

      Because an incredible percentage of products get canceled and the marketing people have learned not to waste their time on some shiny new idea that's probably going to get canceled anyway. Wait a few months and see if the project survives and it's worth investing your time, because if you touch/interact with a project and it's canceled, that of course makes you look bad and has wasted your time. There's the additional benefit that, if the developers are late, that gives you a scapegoat if your marketing campaign isn't ready. And if the developers waste a million dollars redesigning and making changes, it's not your budget and your promotion doesn't depend on helping other departments save money.

      So basically the whole corporate culture exists to make sure that developers can't get meaningful feedback in a timely manner.

      And that's how everything works in a moderately well-run organization. A dysfunctional organization is much, much worse.

    12. Re:Captain Obvious? by New+Breeze · · Score: 2

      That's not the way businesses operate, and the larger they are the more layers of BS things filter through. The person who champions the project hands it off to a subordinate, who hands it off again, etc. By the time it gets to the poor sap who had to bid out the project you're lucky if you get a cocktail napkin sketch of a UI concept and a few vague notes about what it should do.

      There is another form of this that I deal with quite often, where upper management concieves of something that is totally impractical for the people who will actually need to use it. You go through all the look, feel and features stuff to get what the corporte folks envision and then install it only to find that the operations people won't use it.

      It can be extremely frustrating, but if you were smart about collecting your money you've gotten paid and you're never going to have to support the code.

    13. Re:Captain Obvious? by UnknownSoldier · · Score: 4, Funny

      * Meskimen's Law: There's never time to do it right, but always time to do it over.

      * Ninety-Ninety Rule of Project Schedules: The first ninety percent of the task takes ninety percent of the time, and the last ten percent takes the other ninety percent.

      http://www.panopticoncentral.net/2010/08/01/murphys-computer-law/

    14. Re:Captain Obvious? by Phrogman · · Score: 4, Insightful

      That implies that all of those people care to spend the time meeting - and they often don't - and also know or are willing to listen to a detailed explanation of what is involved - and they aren't or are not capable of it. Everyone knows the problems, no one admits to their part of the problem.
      Also management tends towards Seagull management - arrive suddenly, shit all over everything until everyone is worked up, then leave. Rinse, repeat until the project is done or cancelled.
      Honestly I have been through this sort of cycle a few times, and despite the best efforts of the developer side to get management to agree to the design document as defined, the end result is featuritis, people sticking their nose in who shouldn't be able to but who are higher up in the food chain than you (or anyone else in development) is etc.
      Half of the art of software design is dealing with people who don't understand it, or care to learn.

      --
      "The first time I got drunk, I got married. The second time I bought a chimpanzee, after that I stayed sober" Arian Seid
    15. Re:Captain Obvious? by New+Breeze · · Score: 3, Interesting

      The creaping featuritis thing amazes me to this day. I am a codeslinger, if you want it I'll write it. But I will tell you if I think you're making a mistake.

      One of my old bosses put it well when a customer was questioning my opinion on some of their stuff I was pushing back on.

      "If he thinks it's a bad enough idea to tell you that you shouldn't have him do it, you should f'ing listen. You do remember he bills by the hour? If he's telling you it's not something you want him to do he's doing you a favor. And if he won't do it there's no way in hell we'll do it for you, he's the guy we send people to for crazy shit."

    16. Re:Captain Obvious? by Phrogman · · Score: 2

      I recall reading about someone being brought in to replace the (sole) developer for a key piece of business software because the previous one had been fired. (Caveat: I have no idea if this is true and can't recall where I encountered it).

      They opened up the source code to give it a check and discovered that the previous developer had used variable names that varied mostly in the number of letters used. So you had variables named like:
      $m, $mm, $mmm, $mmmm, $mmmmm, $mmmmmm,
      $sa, $saa, $saaa, $saaaa

      and so on. Not a single variable that appeared in the software had an even vaguely informative name. There were no apparent notes to help translate it at all (the previous developer likely left with them).

      Massive job security I suppose but I think I would want to hunt them down and murder them myself.

      --
      "The first time I got drunk, I got married. The second time I bought a chimpanzee, after that I stayed sober" Arian Seid
  3. Obligatory XKCD by doubleplusungodly · · Score: 5, Funny
    --
    ---
  4. same... by jimpop · · Score: 2, Insightful

    It's no different than business school examples vs real world practice.

    1. Re:same... by Anonymous Coward · · Score: 4, Funny

      It's no different than business school examples vs real world practice.

      And English class samples (such as books and essays that they have you read) versus the comments you read on YouTube.

  5. Sounds like sour grapes to me. by Jane+Q.+Public · · Score: 2, Interesting

    Author of TFA had some bad experiences, worked for some bad software houses, generalizes it to "everybody".

    I do not agree that his generalization is necessarily valid. Sure, code in the real world seldom looks like code in textbooks, because code in textbooks is usually designed to solve a discrete problem in a stand-alone way. In the real world, this code will be part of a larger system under circumstances that are less ideal. (Different business requirements, or slightly different mode of operation, etc.)

  6. Given by vanyel · · Score: 2

    It's "rarely acknowledged" because it's just a given...

  7. School code by phantomfive · · Score: 5, Insightful

    The opposite is true too: code you see in textbooks is often horrible. It omits error checking, often uses global variables, makes assumptions, etc. Someone mentioned that K&R has memory leaks all over the place, because it's more readable.

    The goal of textbook code is to be readable, to communicate, not to handle every possible case. This means industry code is often less readable, but more solid. I'm sure I've missed other ways academic code is bad.

    Of course a lot of industry code is unreadable and also not solid. That's another issue.

    --
    "First they came for the slanderers and i said nothing."
    1. Re:School code by GGardner · · Score: 4, Insightful

      I'm sure I've missed other ways academic code is bad.

      The biggest difference is that academic code is _short_. If your whole code base is 10k lines, it's easy to cover all the requirements in a clean design. If you are dealing with millions of lines, there's all kinds of oddball unforeseen interactions and requirements that pop up way late in the game.

    2. Re:School code by arielCo · · Score: 2

      Textbook code is meant to illustrate only the thing being discussed. A book would be less readable if every snippet contained the proper boilerplate for exception handling, pre-execution checks, malloc+free tracking, etc... That's usually covered in separate sections, and the professional coder should be aware of the need even if K&R didn't lecture him on it.

      --
      This post contains no rudeness or derision of any kind. All arguments are friendly. Terms and exclusions may apply.
    3. Re:School code by SydShamino · · Score: 3, Insightful

      This is what I came here to say. (Disclaimer: I'm a hardware engineer and most of the code I write is in HDL.)

      There are two factors at work.
      1. With the exception of big thesis-style projects, most academic work is scoped for you by the nature of the assignment or the teacher. This is almost never true in the real world.
      2. When options are available, the proper way to write code is the way that is most readable and supportable. However, the most readable way to write a given piece of code varies by its scope.

      Thus, as you work on real-world code, you might design something a certain way because it's the cleanest, most readable way you know. Then, later, as the scope of the project is made more clear, either through your own investigation or through changing business requirements, you have to modify the code, but you don't have enough time to toss it all out and start over with a new design that is the most cleanest, readable way to do things given the new requirements. This is most especially true when the scope changes in little steps, each one of which seems small enough to not be a big deal.

      My example is with state machine design. For a simple system that moves between a few states and has a few Moore outputs, a single-process state machine with good state names and a few comments is readable and supportable - it all fits on one page. But if I'm designing a 50-process state machine to handle a big, complex process (and can't break it down into multiple machines for timing or whatever reasons), then I'll use a multi-process state machine, with state and nextstate separated, and probably a dedicated process for each I/O or group of I/O signals, where each one can get it's own page-sized bit of code and comments. The latter style is much harder to read and follow for simple systems, but if the former type morphs into the latter type, I need to cut it out and start over. That's only possible when time permits, and I don't own my time when I'm on the job.

      And all of this assumes that you even bothered to write the code the most readable and supportable way the first time. Far too often the first time code is written, it's written to get "something out there working" so the analog guys or marketing can test their stuff or show it off. And then you don't get time to even fix that code into something readable in the first place. With a project manager and a few software and analog engineers waiting on you, demanding time to do things right the first time can be challenging.

      --
      It doesn't hurt to be nice.
    4. Re:School code by narcc · · Score: 2

      Good as in what?

      Good as in "pedagogically sound"? As that is the sole purpose of the code in question, if it meets that criteria, then it's good code.

      Colleges and universities aren't trade schools, you know.

  8. No surprises here. by csumpi · · Score: 5, Insightful

    Because in real life:

    - specs change constantly
    - need to work with crap that's already there
    - there are deadlines
    - need to get stuff done

    And I'm pretty sure I'm forgetting some other points.

    1. Re:No surprises here. by Xtifr · · Score: 3, Insightful

      - Requirements are messy (even not counting the fact that they change constantly)
      - Textbook code is designed to look clean, but often ignores important edge cases for the sake of simplicity. (See previous point.)
      - Cleaning up the code may potentially introduce bugs, so once the code gets past QA, it's often considered untouchable until a demonstrable problem is found.

      I'm sure there's even more...

      (Test-Driven Development (TDD) is supposed to help address that last point, but A) it's not always perfect, and B) it's not universally used.)

    2. Re:No surprises here. by jnaujok · · Score: 3

      You forgot:

      - No one is willing to fix code that already exists because it works "good enough"
      - No one is willing to expend the resources (read time and money) to go back and rewrite bad piece of code.
      - Fear of new code exposing how bad the other code is.

      (32 years of real world coding.)

      --
      Life, the Universe, and Everything... in my image.
    3. Re:No surprises here. by gutnor · · Score: 2

      Another one: in real world you get stuff wrong.

      • * Because you are just human and if you code 8 hours a day, 250 days a year, a few of your numerous mistakes will made it through to the client.
      • * Then you get stuff wrong because you are not alone, and communication between humans is hard, so hard that it is another profession altogether. Something will eventually be lost in translation situation between you, your team, your bosses, your client.
      • * More importantly, unlike in the books, most of the choices you make do not have a right or a wrong answer. You chose a solution and you know if you right down the line.

      Being wrong require costly rework, or the mythical "phase 2".

      Last one: code in books and academia sucks.

    4. Re:No surprises here. by jimshatt · · Score: 2

      In my company too, refactoring is considered taboo. (hey, that rimes!) Code gets copypasted all over the place because nobody dares touch a piece of working code. So when a bug is found in the duplicated code, it's fixed in 7 out of 10 (all slightly different) duplications (or worse, just the one place the bug shows up).
      I rather take the blame when a new bug is introduced by refactoring a piece of code so it can be used from multiple sites, than create another duplication. I then usually mumble something about not having unit tests, but I know that even with that minor new bug, I've probably saved the company 10 major bugs (and a few depressions from later maintainers)

  9. School v. Reality by girlintraining · · Score: 5, Insightful

    This just in: Examples provided in school have no practical real world application. Duh. In the real world you have things like deadlines, bosses, and clueless managers. When you screw up in class, the teacher tells you where you messed up and you get a chance to do it again. In the real world, when you screw up you probably won't know what you did, at least not right away. And you're going to have to figure it out while everyone is mad at you, calling your phone, and asking why it died.

    I don't know where this idea of the Zen Programmer(tm) comes from with visions of calm blue waters and bright bleached sand and everything is calm, thought out, and composed. Programmers I know hammer down mountain dew like it's nobody's business. They do not spend months debugging and thinking about it academically: If it works, you move on to the next thing. Don't bitch about the quality of the code (manager or academic) in the real world because there are almost no programmers in the corporate world that sit around thinking in O notation and figuring out the best and worst case scenario for every line of code. They bang out 500 lines in a few hours and then hit compile and hope to god it works on the first go.

    That's reality people -- you don't have the time, the resources, and if you took the academic attitude to work with you, you'd be cut up and used as shark food by everyone else for being so damn slow and pragmatic when they need things working tonight so they can go home after being there for 15 effing hours to make the latest milestone.

    --
    #fuckbeta #iamslashdot #dicemustdie
    1. Re:School v. Reality by neminem · · Score: 2

      Really? Generally speaking, when I was in school, when I turned in a homework assignment, I was told where I messed up, and then went on to the next assignment. Only rather rarely was I given even one assignment to fix any of my previous mistakes, as far as coding went, and the only time there was any kind of "keep fixing it until it's fixed" mentality to any school-related project was my whole-year-long senior project... which was part of a program designed to give us real-world experience by giving us actual real-world assignments paid for by companies. (The company I was working for that year hired me when I graduated, and I'm still working there!)

      Yes, sometimes due to deadlines (or simple cost-benefit analysis), not everything will always be perfect when it ships, but I'd certainly always take code written by a company and designed to be shipped, over code designed to be written and turned in as a homework assignment...

    2. Re:School v. Reality by SirLurksAlot · · Score: 3, Insightful

      Don't bitch about the quality of the code (manager or academic) in the real world because there are almost no programmers in the corporate world that sit around thinking in O notation and figuring out the best and worst case scenario for every line of code. They bang out 500 lines in a few hours and then hit compile and hope to god it works on the first go.

      That's reality people -- you don't have the time, the resources, and if you took the academic attitude to work with you, you'd be cut up and used as shark food by everyone else for being so damn slow and pragmatic when they need things working tonight so they can go home after being there for 15 effing hours to make the latest milestone.

      You're working with the wrong programmers then. See, you want the ones that write quality code and test-drive the crap out of everything so they don't have to put in 15 hour days to make the latest milestone. By the way if you're working 15 hour days it means you're mismanaging your manager and their expectations (and/or you suck at your job).

      --
      God, schmod. I want my monkey man!
    3. Re:School v. Reality by jareth-0205 · · Score: 4, Insightful

      You're working with the wrong programmers then.

      Yes, because it's always possible to work with the best programmers the world can provide. In the *real* world there is a finite availability of top programmers, and they might not be working where you are.

      You show yourself to be very naive if you think that every business has the time to let you do TDD, and will provide you with a perfect, experienced team of developers.

  10. Re:From the article by Samantha+Wright · · Score: 4, Funny

    The last page bashes Haskell using a snippet from Uncyclopedia as anecdotal evidence that it is "all but impossible to write readable code" in Haskell.

    Beyond it is another dimension: a dimension of whinge, a dimension of fallacy, a dimension of diminished journalistic integrity. You're moving into a land of more shadow than substance, of vague and half-baked wit; you've just crossed over into the Register.

    --
    Bio questions? Ask me to start a Q&A journal. Computer analogies available for most topics!
  11. In Other News... by SirLurksAlot · · Score: 4, Insightful

    Water is wet, the sky is (perceived as) blue, the world *did not* end, etc.

    On a more serious note I wouldn't describe any of the code examples I encountered in school as perfect or "well-thought-out" specimens." Nearly every one of them was a trivial case which ignored most error cases and expected the client human/system/software to be well-behaved. I've often thought that Comp. Sci. students (3rd or 4th year) should be forced to pick up someone else's code and refactor it into something workable. I'm not talking about the disgustingly huge and unmaintainable messes that we work with out in the real world, but something big enough to give them an inkling of the kind of scope they'll be expected to deal with.

    I also think that if you're not learning TDD in school these days you're not getting your money's worth, and you'd actually be jeopardizing your career by not learning this early, as it is a life-saver out in the real world.

    --
    God, schmod. I want my monkey man!
  12. A soccer team analogy . . . by PolygamousRanchKid+ · · Score: 4, Insightful

    In the academic world, if you were tasked with picking a perfect team, you would steal players from Real Madrid, FC Barcelona, a fistful of Germans, Franck Ribery, etc.

    In the real world, if you are tasked with managing a programming project, you don't get to pick the best. You are given some young kids with more energy than sense, an old, wise, but disgruntled experienced guy, who nobody listens to, a few folks who really don't give a damn, and most of them really truly detest each other. So you try to make out as well as you can, with what you've got.

    Hey, Mercedes are great cars, why isn't every car built like them? Well, not everyone can afford a Mercedes, and maybe most folks can get by with just a Ford.

    It's just the reality of life vs. theoretical academics. Despite the physics problems you solved in college, there are no frictionless surfaces. Or the ones that are available, you just can't afford.

    --
    Schroedinger's Brexit: The UK is both in and out of the EU at the same time!
    1. Re:A soccer team analogy . . . by LDAPMAN · · Score: 3, Informative

      Wrong. My Benz has 11 airbags. My Fordrd does not. My Benz has massive brakes that can bring me to a stop in 1/3 less distance. The list goes on and validates the previous posters point.

  13. I think he's mostly correct by Chirs · · Score: 4, Interesting

    I work in enterprise embedded stuff where the systems are five nines reliable, and even there we've got problems. We recently ran into a day-one bug that suddenly turned and bit us because we switched to a different brand of hard drive.

  14. most claiming crap code by codepunk · · Score: 3, Insightful

    Most of the time the person claiming the code is crap is the one I find to be most to blame.

    --


    Got Code?
  15. other way around? by Anonymous Coward · · Score: 2, Interesting

    I've worked in opposite land apparently... Code quality output by a team of well-vetted coders that I used to work with was high by my standards - low bug rate, decent code coverage for unit tests, generally well documented.... Then I moved to a place where the product was a postgraduate project from a dozen or so CS students. No documentation, ill thought through design, no unit tests, and unmaintainable architecture choices. Why? No real-world experience and no reason for polish, so long as a "working" proof of concept doesn't fall over while being evaluated. (Among other things.)

  16. Obvious Observation, Misleading Conclusions. by VortexCortex · · Score: 5, Informative

    Yeah, they're right about the state of things, but they get the "why" part totally fucking wrong:

    The most common reason for the existence of bad software is bad programmers.

    NOPE! Bad software is a result of BAD Code, even good programmers can write bad code...

    At the other end of the spectrum, many projects are sabotaged by developers who are “too good”

    NOPE! Maybe those scare quotes are there for a reason, but "doing things the most complex way possible" is usually because coding is iterative and there was no way for you to know of the unforeseeable future requirements.

    And then there’s “bad” laziness, the kind that leads programmers to cut corners or do things in the quickest possible way, rather than taking the three extra hours to do them right.

    NOPE! You're assuming that the programmer WANTED to do things the quickest way possible...

    If the system is working, almost no manager will pay just to have you recode a piece of it “the right way,” without adding any new functionality. There’s always something more important that needs to be done—until that quick-and-dirty fix blows up and (because it’s urgent) gets replaced by another quick-and-dirty fix.

    BINGO! This. Everything, all of the other bullshit is due to Management. Not just not paying to have things done right (see: Fast, Good, Cheap), but also unrealistic schedules and deadlines, new features being promised by sales without consulting the programmers, etc. Deadlines exist. That's why even a good programmer hacks in a kludge ridden short cut instead of taking the time to do it the right way: There is no time to take! The most common reason for bad software isn't bad programmers, is bad management and terrible working conditions. See also: Getting what you pay for when you outsource the programming department. The outsourced workers will get it done cheaper in less time -- Cheap, FAST -- What's missing here, eh? GOOD Sadly to compete with the fast and cheap the goodness of the software must be sacrificed.

    As mentioned above, C++, despite its superficial similarities to Java, is infinitely easier than Java to write impenetrable code in. And one language I’ve been warned about, though I’ve never had the opportunity to use it, is Haskell, an offshoot of ML. According to a friend in academia who’s studied it, it’s “the Taliban version of ML,” in which it’s all but impossible to write readable code.

    Just stop talking noob.

    In the real world, tight budgets, shortsighted managers, and unreasonable expectations from non-techies almost always conspire to make developers do things too quickly.

    You mention this and yet you somehow fail to realize THIS, not Languages, not Laziness, not Ignorance, not Hubris, is what is really the root cause of all the damn evil?! Fuck you, man. You're part of the problem.

    In conclusion: Bad software is primarily a result of GREED.

  17. How to make real code that is good by Brett+Buck · · Score: 2

    The article appears to mostly be self-indulgent/elitist crap, but there is a kernel of reality in it.

          What some of my colleagues and I have done to avoid the "obscure features" problem of "expert coders" is to ban their use. A particular language we use permits many fairly obscure features that lend themselves to writing mystery code. We simply don't use them unless absolutely necessary. This is embedded spacecraft code, we only need basic relational statements, math functions, and minimal pointer use. So we don't use some of the more obscure features (doubly-defining tables, unnecessarily complex data structures, the more bizarre capabilities of pointers, etc). The code is still maintainable 30 years later, people can pick it up and read it from cold, and modify it with ease and safety.

  18. communicating well is hard by binarstu · · Score: 3, Insightful

    From TFA: "Good software, misleadingly, is usually easy to read, but it’s not easy to write."

    What is misleading about that? The same could be said for any of the formal mechanisms we've invented for expressing our thoughts and ideas to other humans. Good oratories, good lectures, good books, good journal articles, and so on, are all easy to consume, but speaking or writing well requires tremendous effort and practice.

  19. Just like the Boy in the Bubble by Dave+Emami · · Score: 3, Interesting

    You look at it as "the real world sucks." I look at it as "college doesn't prepare you for the real world." It doesn't prepare you, because it doesn't expose you to it at all.

    In college (at least, when I was there), the focus was entirely on showing you good code, not showing you bad code. This is like running a medical school where the doctors-in-training only see top-form athletes and never get a glimpse of sick people. Beyond lack of experience, a lot of the time the best way to understand why certain standards or principles are good is to see what happens when they're not followed, and you just don't see that in a classroom.

    At the risk of drifting into "get off my lawn!" territory, allow me to give an example I experienced.

    During my classes ("software engineering principles" or something like that), one of the things we went over was coupling, and why loose coupling was better than tight coupling. Passing parameters is better than using a global variable, which is better than reaching into another module's guts, etc. All very reasonable, and everyone agreed that it made sense. However, nobody, including myself, seemed to give it much weight. Most of us already coded that way, anyway, so it wasn't any big revelation.

    A few months later, at a job that involved maintaining and extending a decent-sized (by early 90s standards) application, I had to work with code by a guy who declared a single variable, "s", as an 80-char string, and used that all over the place. Different functions read and wrote to "s" at their whim and without regard for what other code might be doing with it. It was used in place of function parameters, in place of function results, and sometimes just as a temporary variable. Naturally, this caused all sorts of difficult-to-predict bugs. It was when dealing with this crap that a light went on in my head and I realized, "Oh! This is what the prof meant when he said tight coupling was bad!"

    --

    "The Greens lynched a hacker in Chicago. Last month, but I think the body's still hanging from the old Water Tower."
  20. Related, featured on /. a few months ago by arielCo · · Score: 2
    --
    This post contains no rudeness or derision of any kind. All arguments are friendly. Terms and exclusions may apply.
  21. You think that's bad by HangingChad · · Score: 4, Insightful

    Obviously the author has never tried to untangle outsource code. If he thinks home grown code is bad, wait until he wades through a bowl of Bangalore spaghetti code. Yummy.

    Although I did make a lot of money sorting through that crap. Many companies would just assume outsource code would work when they needed it and couldn't figure out how come their wonder app, that they got done for half of what U.S. programmers would have cost, kept crashing.

    --
    That's our life, the big wheel of shit. - The Fat Man, Blue Tango Salvage
    1. Re:You think that's bad by CodeBuster · · Score: 2

      YES! The Indian outsource shops especially are notorious for producing poor quality code that fails to meet required minimum standards for what's acceptable in most American and European companies. To any managers out there reading this, beware of outsourced development. IBM and other big tech companies get away with it because they run their own operations in India and hire the better people. This leaves only the bottom of the barrel for your next outsourced project. That bid was cheap for a reason so don't be fooled. Hire an American instead or you'll be wishing that you had when the consultants hand you their bill for what it will cost to "fix" the outsourced project.

  22. It's all relative by davidbrit2 · · Score: 2

    This is why I use Access a lot. Compared to the awful ERP and operational software that's out there, the little things I throw together look perfectly fine. And if I can go from concept to deployed application in an afternoon, then that's less cost to the business. We had an old RMA tracking application written in VB6, that had the database server name hard-coded. I spent a couple of hours with Access, totally rewrote it, and actually made it better. I certainly wouldn't write an entire accounting system in Access (probably), but in a world of software written with necessary business constraints and compromises in mind, do as the Romans do.

  23. Re:Its a joke right? by RabidReindeer · · Score: 2

    Are you kidding? I do systems programming code all day In C/C++, and the hacker code in the ANSI C book is a steamy pile of crap. We would have security problems, and hard to find bugs all over the place. This is not to mention that our static analysis tools would prevent such code getting into our code base.

    Try the Enterprise Java books, instead. J2EE has a built-in security framework. It's not very sophisticated, but it's well-tested and it intercepts many types of exploits before they can get anywhere near the application code.

    On the other hand, I've seen many DIY login/security systems over the years and most of them are total tissue paper security-wise.

    So what do all the Enterprise Java books use for examples? DIY login screens!

  24. Re:Academic by DragonWriter · · Score: 2

    Personally, I find academic code -- that found in textbooks and other teaching materials -- to be poor specimens. These are examples that teach methods and concepts, but utterly fail to account for edge cases and real-world scenarios. Real-world code may not always be pretty, but it is a lot more comprehensive than what you will find in textbooks.

    IME, the exact opposite is true; code in textbooks is far more often to address a specifically defined problem domain correctly (often, a problem defined in such a way that edge cases which might be important in a "real world" program are outside of the problem domain, but nevertheless the specified domain is correctly addressed -- the exception being code in textbooks that exists specifically to support exercises which address identifying and addressing edge cases that are within the problem domain), whereas with real world code it is often the case that the problem domain is -- even if you are lucky enough to have design documentation accompanying the code -- poorly specified, and quite often the code is not correct for the problem domain and fails to account for edge-cases and real-world scenarios that occur both in the defined problem domain (to the extent that such a thing exists) and the actual domain in which the program is applied.

    Though its true that the real world code is often more "comprehensive", if by that you mean the opposite of "concise" rather than the opposite of "incomplete".

  25. I beg to differ with the author by volvox_voxel · · Score: 2
    Most text books are very simple relative to real-world code, and a great many books out there are average or poor. A large percentage of the code that you find on the internet is also bad, but it's often better than what you can find in textbooks. I've been a programmer for more than 10 years. Most of the code I have been exposed to has been pretty elegantly written. Well written code is probably more common than poorly written code for software engineers in Silicon Valley, though my vantage point is rather limited. Employers don't pay through the nose for Spaghetti code.. Silicon Valley is, by and large, a meritocracy. Well written code begets higher titles, salaries, other ventures with the like-minded.. Well written code is easily recognizable by your colleagues.

    I've always held that 90% of anything is bad with respect to books, movies, music etc. After 10 years, the good authors tend to stand out.

  26. Re:Skimmed article - more than it deserves. by Jeremi · · Score: 2

    Ah, Slashdot... where a post about the importance of "people skills" can't go for more than a sentence without calling someone a "moron" or an "asshole".

    I get the feeling that Anonymous Coward was actually this guy.

    --


    I don't care if it's 90,000 hectares. That lake was not my doing.
  27. Reality by degeneratemonkey · · Score: 2

    Code is bad because of deadlines, everyone seems to agree.

    Bad is relative though. If the software satisfies its business case, and ultimately doesn't have unmanageable maintenance costs associated with it, it's basically good regardless of its failure to meet standards of elegance and clarity.

    People write good real-world code all the time, and most of it is open-source. You can attribute bad industry code to greed, and that's valid, but it doesn't necessarily imply that the result is bad. Greed isn't going anywhere and greed builds some useful stuff amidst all the messes it creates.

    Even in the projects where time is not a constraint, growing complexity often leads to programmers making design compromises. These aren't necessarily as heinous as what you find in profit-driven code, but they exist because software is hard to get right when the problem being solved (i.e., the set of requirements) is almost always a moving target.

    There is always a compromise between toiling endlessly in the realm of over-engineering, or shipping a release some time in the next century.

  28. the best companies have both by RedHackTea · · Score: 4, Insightful

    When I first graduated college and got a programming job, I thought the code was a bit shit too. Then I learned about deadlines and most importantly Bit Rot. I soon realized that you need both strokers and crankers to make a successful company (I like bowling terms).

    Crankers bang out code like there is no tomorrow. When good managers find these people, they immediately put them in the department of developing new features. Competition is fierce, and a lot of times it doesn't matter about quality but about who gets there first. End of story.

    Strokers take their time with code. They are fit for the "support queue," debugging, and any specific jobs that require needlework precision. I work in this department. I fix a lot of code made by Crankers, taking in both memory-efficiency and speed-efficiency. So when a customer finally does have 10,000 loads which the Cranker didn't foresee in his/her code, I fix it, and the customer is happy. I also provide a lot of options to the user instead of forcing the user down one path. Lastly, I do jobs that require excellent quality. Do not give money-critical new features to Crankers; give them to Strokers. I actually have used a lot of the the computer sciencey things that I learned in college like Big O, various Dijkstra algorithms, etc.

    Tweeners are the in-betweens. They are good for the basic infrastructure/architecture. They write the base library fast and with decent enough quality. For example, they may write layers around the database, GUI, etc. to make life easier. If you don't have a Tweener, then use a Stroker. If you need the product out fast though, use a Cranker and then a Stroker later on to refactor, or use a Cranker and Stroker in unison.

    To make a killer software company, you need all three. And the companies that last a long time, have managers that know how and where to place these people.

    --
    The G
  29. Call me crazy by eWarz · · Score: 2

    Call me crazy, but i think we spend too much time on complex OOP based code. No I'm not making this up, I might know more languages than you, but I've also had the unfortunate opportunity of working on more shit code than most people. We need to go back to basics. When a company can hire a 3rd party team to write a 3rd party CRM cheaper than it is to modify an internal CRM there is a problem. Pay attention to this next part: When a class library becomes so complex it takes more time to maintain the library than to write new functionality, you have a problem. It should be easy to understand a code-base without spending days learning an API. code needs to be more adaptable to chancing situations. When a pharma company can spend $600,000 per year to maintain a 3rd party CRM because a first party CRM costs millions to mod, there is a problem. Just my observation though. *glares at top 20 pharma companies* thx for the awesome paycheck.

  30. It's Terrible Because Nobody Wants to Pay by CodeBuster · · Score: 3, Interesting

    The simple truth of the matter is that most commercial code is written by overworked developers on tight schedules and with miniscule budgets. The managers crack the whip and rush things along because the people who sign the checks don't care about quality code if it means that they won't have a "first mover" advantage in the marketplace. This is particularly true in the consumer space and the phone app world. Much of that code is just pure shit. Ironically, some of the best and worst code that I've seen in the wild comes from the open source community. Is there any good commercial code out there? I'm sure that it does happen from time to time in mature products. The engine control unit in your car or perhaps the drill bit controllers on oil field equipment or maybe the hard disk controller, but in my experience crappy code is the rule and quality is the exception. Users rarely perceive quality as long as they system works, so few are willing to pay more for it in either time or money.

  31. Re:My life is hell by CodeBuster · · Score: 2

    Crappy, hard to maintain code helps you stay employed

    How would you feel if the people that made your car shared that sentiment? It's attitudes like that that give the profession a bad name. Take some pride in your work and don't be the guy that's cursed by everyone who comes after you.