Slashdot Mirror


Dr. Dobb's Calls BS On Obsession With Simple Code

theodp writes "Over at Dr. Dobb's, Editor-in-Chief Andrew Binstock has a nice rant on The Misplaced Obsession with Simplicity. 'Any idiot can write complex code,' goes the old maxim, 'the true art is writing simple code.' Right, Andrew? Wrong (mostly). Binstock explains, 'It's not true that any idiot can write complex code. Complex code is difficult, often very difficult, to write. It's entirely true that it's more difficult to maintain, too. But that's the nature of complexity. Some things are intensely difficult to express in code and they require complexity, simply because they're not inherently simple.' After citing the complex-but-necessarily-so code of Al Aho and sometimes-misguided reverence for cyclomatic complexity limits to help make his point, Binstock concludes, 'My view of simplicity is unemotional and free of idolatry because I define it with respect to complexity, rather than the other way around: Simplicity is the quality of code that is no more complex than required to express the underlying complexity. In this way, simple code can be intensely complex. There is no inherent good/bad dichotomy.'"

381 comments

  1. To quote Einstein by BenSchuarmer · · Score: 5, Insightful

    Everything should be made as simple as possible, but not simpler.

    1. Re:To quote Einstein by invid · · Score: 1

      Everything should be as complicated as it needs to be, and no more complex.

      --
      The Moore-Murphy Law: The number of things that will go wrong will double every 2 years.
    2. Re:To quote Einstein by Anonymous Coward · · Score: 0

      The article could've been simpler.

    3. Re:To quote Einstein by Anonymous Coward · · Score: 1

      BTW did Einstein really say that, or was it attributed to him by default?

    4. Re:To quote Einstein by girlintraining · · Score: 5, Funny

      That quote is attributed to Einstein, but you should know by now a great many quotes are attributed to him, but very few can be proven to have been from him. -_-

      "There's no such thing as a correct quote citation on the internet." -- Abraham Lincoln

      --
      #fuckbeta #iamslashdot #dicemustdie
    5. Re:To quote Einstein by Anonymous Coward · · Score: 0

      That's too simple of a dictum, though: Sometimes there are benefits to added complexity that aren't required but may be worthwhile anyway. It's possible to make some of my work simpler, but is the added complexity worth the benefits? There are value judgments involved, not the black and white of possible/impossible.

    6. Re:To quote Einstein by Spy+Handler · · Score: 5, Informative

      It's paraphrase of Einstein who said something like that at various times in his life, but not those exact words.

      Here's an exact quote from Einstein:

      "It can scarcely be denied that the supreme goal of all theory is to make the irreducible basic elements as simple and as few as possible without having to surrender the adequate representation of a single datum of experience." - From "On the Method of Theoretical Physics", Oxford, June 10, 1933.

    7. Re:To quote Einstein by lgw · · Score: 4, Insightful

      Arguing against stupid "complexity metrics" is fair. A programmers job is to game the system. Give him a metric other than making the customer happy, and it will not end well.

      But I've seen far too much code that was simply far more complex than it needed to be. Stop tripling the size of your code for use-cases that no one has asked for, people!

      If you can make assumptions that significantly simplify your code, and those assumptions fit within the actual, stated requirements of the work (ignoring requirements that exist only in your head), for goodness sake make those assumptions.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    8. Re:To quote Einstein by Drethon · · Score: 1

      Or as they say with requirements. The best requirement is usually the shortest requirement that is complete and unambiguous (plus a few other things depending on the software level).

    9. Re:To quote Einstein by 93+Escort+Wagon · · Score: 3, Funny

      In the words of Albert Einstein: "I never said most of the things I said."

      --
      #DeleteChrome
    10. Re:To quote Einstein by internerdj · · Score: 4, Insightful

      Not all customers are smart enough to know to ask for everything. Even a smart customer may not be able to give you a real answer for what happens in X cornercase. Presumably you (or someone like you) are being paid to hash out all the hidden requirements and assumptions to achieve the customer-stated requirements.

    11. Re:To quote Einstein by lightknight · · Score: 1

      Indeed. Simplicity is but an ingredient to the main dish that is perfection...it is not the sole ingredient; too much, and the flavor is ruined; too little, and the inner ideal is never glimpsed.

      --
      I am John Hurt.
    12. Re:To quote Einstein by sosume · · Score: 1

      "There's no such thing as a correct quote citation on the internet." -- Abraham Lincoln

      pure gold

    13. Re:To quote Einstein by Anonymous Coward · · Score: 0

      Ah, I see you take your inspiration from ToadyOne.

      Good man, good man.

    14. Re:To quote Einstein by Baby+Duck · · Score: 1

      “Perfection is achieved not when there is nothing left to add, but when there is nothing left to take away” – Antoine de Saint-Exupery

      --

      "Love heals scars love left." -- Henry Rollins

    15. Re:To quote Einstein by RabidReindeer · · Score: 1

      Everything should be made as simple as possible, but not simpler.

      My first rule in software design. And the second one is:

      Simple things should be simple and complex things should be possible.

      Alan Kay

    16. Re:To quote Einstein by djdanlib · · Score: 2, Interesting

      Stop tripling the size of your code for use-cases that no one has asked for, people!

      Yeah, just let it throw a bugcheck when something happens outside of the design parameters and let the user sort it out with your support department. /sarcasm

      Security risks. Data corruption. Performance edge cases. Productivity loss. Unexpected bluescreens. Actual damage to physical hardware controlled by the software. You know all that bad stuff could have been easily prevented if the programmer anticipated those situations, and the people hiring that programmer probably expected the software to be well-made... It's much less expensive to do it ahead of time than to fix it when it breaks. Change in development = cheap, change in production = expensive.

    17. Re:To quote Einstein by dkleinsc · · Score: 1

      Actually, that was Yogi Berra.

      --
      I am officially gone from /. Long live http://www.soylentnews.com/
    18. Re:To quote Einstein by cold+fjord · · Score: 1

      Everything should be made as simple as possible, but not simpler.

      You know you've gone too far with "simplicity" when it no longer solves the problem, or when a modest increase in complexity or sophistication in expression would result in meaningful gains in some aspect of performance, simpler code in other code sections, or ability to maintain the code. Ideally it is subtle and simple, but sometimes subtle versus simple.

       

      --
      much of left-wing thought is a kind of playing with fire by people who don't even know that fire is hot - George Orwell
    19. Re:To quote Einstein by Skapare · · Score: 1

      Everything should be made as simple as possible, but not simpler.

      Everything should be as complicated as it needs to be, and no more complex.

      You are being redundant.

      --
      now we need to go OSS in diesel cars
    20. Re:To quote Einstein by Zalbik · · Score: 4, Insightful

      Presumably you (or someone like you) are being paid to hash out all the hidden requirements and assumptions to achieve the customer-stated requirements.

      Yes, but this should be done prior to code writing.

      Far too often I've seen extremely complicated code designed to handle "what-if" scenarios that never happen.

      i.e.
      Developer: "I wrote that configuration module in case they ever need to change the parameters of X"

      Me: "Did you ask if X would ever need to be reconfigured?"

      Developer: "Of course! And the client said that sure, if I could make it configurable, go ahead and do so"

      Me: "And did you ask how likely it would be that X would need reconfiguration? Or under what circumstances X would need to be reconfigured? Or what types of 'reconfigurations' they think they would need? We're looking at 2 man-months of code, plus testing, plus implementation time here....was any kind of cost-benefit analysis done to see whether it was worth it to write this?"

      Developer: [blank stare]

    21. Re:To quote Einstein by Honclfibr · · Score: 5, Funny

      Clearly, not taking his own advice here...

    22. Re:To quote Einstein by gstoddart · · Score: 3, Insightful

      Stop tripling the size of your code for use-cases that no one has asked for, people!

      So, we should stop doing any bounds and input checking if the client didn't ask for it explicitly?

      Is this part of Agile Programming or something? Write the most incomplete code you can get away with because it isn't in the spec?

      I once had a co-worker bitch and complain I was checking the result of every single function, including strprintf() -- he said it was unnecessary. Not long thereafter, we spent some time tracking down a problem which turned out to be in his code, because he wasn't checking anything (again, because it was 'unnecessary').

      If you write shitty, incomplete code up front, it's much harder to make it less shitty and incomplete later. If I know from experience there's a bunch of things that can go wrong, I'm going to try to account for as many of those things as possible when I write it.

      Those use-cases nobody asked for can sometimes be the difference between code which collapses at the first unusual inputs, and stuff which can at least tell you WTF went wrong. Because sometimes, even the simplest of things can fail.

      --
      Lost at C:>. Found at C.
    23. Re:To quote Einstein by INT_QRK · · Score: 1

      Just common sense, eh? Rules-of-thumb as pointers to guide good judgement are often wonderful and ever so useful, but deference to observed truth, grounded insight and informed judgment can be better, especially for people with serviceably functioning minds. Down with fanaticism in all its forms.

    24. Re:To quote Einstein by RedHackTea · · Score: 1

      Why write complex code? Job security.

      --
      The G
    25. Re:To quote Einstein by WillerZ · · Score: 1

      I have never seen a complete and unambiguous requirement for any real piece of software, and I would wager no other software engineer has either.

      --
      I guess today is a passable day to die.
    26. Re:To quote Einstein by lgw · · Score: 4, Interesting

      Those things aren't part of the formal requirements in your world?

      --
      Socialism: a lie told by totalitarians and believed by fools.
    27. Re:To quote Einstein by Anonymous Coward · · Score: 3, Insightful

      Clearly, not taking his own advice here...

      Dude, the man ushered in a revolution in physics. His idea of simple would melt most people's brains.

    28. Re:To quote Einstein by ebno-10db · · Score: 1

      Don't forget Mark Twain and Winston Churchill. When in doubt (and often when not) quotes are attributed to one of the big 4: Mark Twain, Winston Churchill, Albert Einstein and Yogi Berra. Occasionally Will Rogers gets an honorable mention.

    29. Re:To quote Einstein by lgw · · Score: 1

      Some requirements come from the customer. Some come from basic quality standards. All of which misses the point: that sanity checking never makes the business logic any more complex, it's just more lines of code to handle the stated use case correctly. As I said: stupid complexity metrics are stupid.
       

      --
      Socialism: a lie told by totalitarians and believed by fools.
    30. Re:To quote Einstein by lgw · · Score: 2

      Very well put. So much needless code comes from trying to support actions that the customer will never actually care about.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    31. Re:To quote Einstein by gstoddart · · Score: 4, Interesting

      Those things aren't part of the formal requirements in your world?

      I've never seen formal requirements which detail every edge case I need to account for.

      There's an assumption we'll be writing robust code, and as it gets created we build in as much error checking and handling as we can think of, and over time you usually end up adding more.

      If coders had to be told in writing every error condition to check for, there wouldn't be any -- because the client wouldn't know (especially true when you have to create a library to do some of the work), and the developers would just say "not in the spec".

      Come to think of it, I've never seen formal requirements for much more than the really high-level systems stuff. From my perspective, a system which has been fully designed and spec'd out before anybody writes code is a myth.

      --
      Lost at C:>. Found at C.
    32. Re:To quote Einstein by Anonymous Coward · · Score: 1

      Am I the only one here who heard of the concept of *efficiency*??

      Efficiency is the whole damn point. Being able to do as much as possible with as little as possible.
      *No matter* which direction you go from optimum efficiency, it becomes worse.
      In one direction you end up with VI/Emacs, and in the other direction... well... remember when MS made that video a four-year-old using Windows 8 without problems?

      It's not just Windows 8, but indeed Apple is completely built around this. Gnome, Chrome, Firefox, any instance of autocorrect, KDE’s Plasma, they all jumped on the dumbwagon like it's the shit. It's all around us. And for a long time too. ShowView, AOL and MS Clippy were very notable early examples.
      In the name of dumbing everything down to a level where *literally* a four-year-old can handle the thing. ... That also is *literally* the intelligence level of a chimp!!

      What it cost us, is an extreme loss of power. We dumbed a *universal* information processing machine--the greatest invention in human history--down to a fixed-function "media" consumption device, preferably with one single giant red touchscreen button with a cryptic symbol on it that means "Guess what I want, and do it!", on which you only have to drool to trigger it. (Aka "Siri Clickwheel 2.0".)
      Of course without every having to tell it your actual preferences. It is just assumed you're part of the herd, and have no free will. So it does what is assumed everyone wants. Without giving you an option to even change it anymore. (Ever seen a Apple/Chrome configuration dialog? The first time I thought "Is that a joke? Where is the rest of the config?")

      Compare even an Android device to a Linux environment with shell scripting, ETIAF, dbus, etc. YOU CAN'T DO SHIT ANYMORE!
      And if you can, it's mind-boggingly convoluted and unless somebody actively tells you, you can't even find it!! (Try deleting somebody on Skype for iOS. Try moving an icon on a different screen on iOS. Where's the fucking menu, so I can see what I can actually do? Where's the labels so I can tell what the damn symbol means and avoid wrecking something? Holding your finger on any icon for x seconds until they wiggle? Hidden double-taps under special conditions? Hidden *areas* where you have to drag and hold something for x seconds, *under special conditions*?? ARE YOU FREAKING KIDDING ME??)

      But that is not the only problem with KISS. The main problem is, that in such situations, people dumb down too. And lose the desire to want anything that's not available. Their mind moves into a really really *tiny* box. The whole bell curve moves downwards.
      And because of the Dunning-Kruger effect, the new low end becomes even louder and even more confident.
      Which the KISS morons only see as it requiring even more dumbing down.
      The end result is what I described above.

      And worst of all, it's completely pointless, since there is no either-or. You don't have to choose between Notepad and Emacs/VI. You can have both at the same time! It's called *configurability*. With good, but *not fixed* defaults.
      But I guess if you're dumb enough, you can't even see the stupidity of your own actions anymore...

      I chose Haskell for a reason. And the reason was, that it is not yet infected by KISSanity.
      Because those morons would definitely kill monads and functors the minute they got in power. For being "too complicated" for their lazy rotten brains.

    33. Re:To quote Einstein by Anonymous Coward · · Score: 0

      Or, if you're offroading on treacherous boulders, as slow as possible, as fast as necessary.

    34. Re:To quote Einstein by Anonymous Coward · · Score: 0

      That quote is attributed to Einstein, but you should know by now a great many quotes are attributed to him, but very few can be proven to have been from him. -_-

      "There's no such thing as a correct quote citation on the internet." -- Abraham Lincoln

      "Vampire are just myths."-- Abraham Lincoln

    35. Re:To quote Einstein by Anonymous Coward · · Score: 0

      So let me get this straight: They made his statement *simpler* than possible, surrendering the adequate representation?
      Oh the ironing!

      Let me make a new quote for you: Everything should be made as EFFICIENT as possible.
      (*Efficiency* is the sweet spot between limiting complexity and limiting simplicity. It can only be improved with more *emergence*. The definition of *elegance*.)

    36. Re:To quote Einstein by ZahrGnosis · · Score: 5, Insightful

      I think you're confusing feature-creep with a comment that was meant to be about edge-scenarios. Allowing someone to configure parameters that were never spec'ed to be configured is feature-creep (gold plating, extra coding, call it what you will), and I agree should be avoided and adds unnecessary (or not obviously necessary) "complexity".

      Handling an edge criteria that was implied but not explicit in a specification is what is typically meant of "corner case", and is not the same thing you described. Recognizing that the customer asked for something logically impossible (they want two data sets to reconcile, but they are at unexpectedly incompatible cardinalities), or something that, upon investigation while building an app, wasn't precise enough (they asked for this to be their standard green, but their standard list only includes red and blue).

      It's nearly impossible to specify all of those prior to coding, which is why the typical "waterfall" development techniques have fallen out of vogue. You're always going to learn things while coding, and this is one of the main contributors towards apparently unnecessary complexity. If I design version 1 of a program perfectly, and customers have new requirements for version 2, it's unlikely that the "simplest" implementation of version 1 will be the one that is most conducive to an upgrade. You end up with a choice between refactoring completely or sacrificing some efficiency and simplicity to graft the new features onto an otherwise good version 1.

      I think Dr. Dobbs is nitpicking, though. There are definitely many ways to address, measure, or understand simplicity, and I agree that it should not be THE goal in and of itself. But the idea of making code easy to read, easy to understand both in the micro and macro sense, and just generally "simpler", has many merits.

    37. Re:To quote Einstein by Anonymous Coward · · Score: 0

      It's paraphrase of Einstein who said something like that at various times in his life, but not those exact words.

      Here's an exact quote from Einstein:

      "It can scarcely be denied that the supreme goal of all theory is to make the irreducible basic elements as simple and as few as possible without having to surrender the adequate representation of a single datum of experience." - From "On the Method of Theoretical Physics", Oxford, June 10, 1933.

      Should I be concerned that this is much more complex than "Everything should be made as simple as possible, but not simpler." ?

    38. Re:To quote Einstein by Anonymous Coward · · Score: 0

      "A gallon of blood saves a pint of sweat." -Joseph Stalin

    39. Re:To quote Einstein by Drethon · · Score: 1

      While the software is running, pixel X:0 Y:0 shall be set to RGB Value 128,128,128.

      Ok, even that can probably be badly nitpicked as I took 15 seconds to write it. And you were probably talking about ideal vs reality. Yeah, I've had my fill of really freaken awesome requirements to work from...

    40. Re:To quote Einstein by 93+Escort+Wagon · · Score: 0

      I guess I should have prepended the following:

      ATTENTION: I AM ABOUT TO MAKE A JOKE.

      As Albert Einstein said: "90% of reading Slashdot is half mental".

      --
      #DeleteChrome
    41. Re:To quote Einstein by sjames · · Score: 1

      The key is to design things to minimize the chance of data corruption when things do go bad (and they will, you almost inevitably didn't think of some corner case somewhere).

    42. Re:To quote Einstein by Anonymous Coward · · Score: 0

      Everything should be made as simple as possible, but not simpler.

      Everything should be as complicated as it needs to be, and no more complex.

      You are being redundant.

      I am being redundant.

    43. Re:To quote Einstein by Anonymous Coward · · Score: 3, Funny

      I've seen extremely complicated code designed to handle "what-if" scenarios that never happen.

      As is usually the case, XKCD covered this well. The image title is particularly good:

      I find that when someone's taking time to do something right in the present, they're a perfectionist with no ability to prioritize, whereas when someone took time to do something right in the past, they're a master artisan of great foresight.

    44. Re:To quote Einstein by Anonymous Coward · · Score: 0

      “Perfection is achieved not when there is nothing left to add, but when there is nothing left to take away” – Antoine de Saint-Exupery

      And here we see the difference between the point of view of a painter vs. a sculptor.

      As for the article, the guy is wrong from the start- he doesn't understand the point of the maxim. Another maxim which expresses the same idea is "Less is more."
      To use a literary example, a good writer can convey an idea in one paragraph while a poor writer needs an entire novel to make the same point. Same thing in coding- a good coder can do complex things with simple code, and a crappy coder will generate complex code to do the simplest of things.

    45. Re:To quote Einstein by lgw · · Score: 1

      Ah, we seem to have lost a vital distinction. I'd would never say "don't do work that's not in some formal spec", because formal specs are never complete in my experience. I'm saying "don't invent use cases". Error checking is not itself a use case, it's just properly written code. Robust code is how you implemented, not what you implemented.

      I'm complaining about where code goes far off into the weeds to support "what if the user wants to do X, or Y, or Z, or T, or U, or V" when the customer only asked for X. Sure, it's good to prioritize the others and see whether they belong in the project, as part of setting the requirements, but it's bad to just add a ton of code "because surely the customer will ask for this eventually".

      --
      Socialism: a lie told by totalitarians and believed by fools.
    46. Re:To quote Einstein by White+Flame · · Score: 1

      Yes, but this [hash out all the hidden requirements and assumptions] should be done prior to code writing.

      That is impossible. Waterfall design cannot cover everything.

    47. Re:To quote Einstein by minogully · · Score: 1

      In the name of dumbing everything down to a level where *literally* a four-year-old can handle the thing. ... That also is *literally* the intelligence level of a chimp!!

      And if you can, it's mind-boggingly convoluted and unless somebody actively tells you, you can't even find it!! (Try deleting somebody on Skype for iOS. Try moving an icon on a different screen on iOS. Where's the fucking menu, so I can see what I can actually do? Where's the labels so I can tell what the damn symbol means and avoid wrecking something? Holding your finger on any icon for x seconds until they wiggle? Hidden double-taps under special conditions? Hidden *areas* where you have to drag and hold something for x seconds, *under special conditions*?? ARE YOU FREAKING KIDDING ME??)

      I see a contradiction here, unless you're implying that you *literally* have the intelligence level of a chip.

    48. Re:To quote Einstein by Anonymous Coward · · Score: 0

      I only trust the quotes that where signed with is private key.

    49. Re:To quote Einstein by Anonymous Coward · · Score: 0

      Allowing someone to configure parameters that were never spec'ed to be configured is feature-creep (gold plating, extra coding, call it what you will), and I agree should be avoided and adds unnecessary (or not obviously necessary) "complexity".

      errm ... setting parameters/defining constants in an extra file should be TRIVIAL. if it's not, the skeleton of your project is bad.

    50. Re:To quote Einstein by Anonymous Coward · · Score: 0

      Well, his native language was German, after all. He wasn't all that comfortable in English in 1933 http://www.princeton.edu/~mudd/finding_aids/mathoral/pmc44.htm .

    51. Re:To quote Einstein by Anonymous Coward · · Score: 0

      Everything should be made as simple as possible, but not simpler.

      Everything should be as complicated as it needs to be, and no more complex.

      You are being redundant.

      But, no more redundant than he has to be...

    52. Re:To quote Einstein by plover · · Score: 3, Insightful

      The efficiency of a system can not simply be measured by CPU cycles. It all depends on where your costs are. Efficiency has to be measured by money.

      If your highest costs are in runtime efficiency, then yes, you need efficient code. But if your highest costs are in end-user time spent entering data, usability beats efficiency. If your highest costs are driven by software engineering practices, such as testability, reliability, supportability, frequent deployments, etc., then readability becomes far more important than efficiency.

      The usability argument works like this: if I have to pay a barrista $10 an hour to touch 20 buttons just to place an order for coffee, and the user time per button press is 3 seconds while the system time per button is 8 milliseconds or less, the efficiency of the code is almost irrelevant. My development investment is best spent in reducing the number of button presses. If a fancy GUI and a magical "do what I want" button reduces the 20 button touches to 10, I can save 30 seconds of labor per cup of coffee. If adding that fancy GUI increases the system time from 8 milliseconds to 30 milliseconds per button press, I haven't actually incurred any additional labor costs because the system is still faster than an average human's response time (maybe not in a highly caffeinated coffee shop, but it's still far less important than saving even a single button press.)

      I've found that in most business applications user time is the largest expense, by a very wide margin.

      If libraries of tested proven code are cheaper than hand written assembler, I don't want to pay a developer to replicate that work, even if it would be theoretically more efficient - unless the program that they're working on has efficiency as the most important goal. If I was developing an algorithm for slinging polygons at a graphics card, you better believe I'd squeeze every cycle out of the GPU. But if I'm figuring tax on a cup of coffee, or the total of a chart on a web site, efficiency isn't nearly as important as provable correctness.

      Lest you think I'm trying to defend the stupid walled gardens of iOS and their ilk's practices of constraining UIs and simpleton features, I'm not. I do think that there needs to be a mix, however. To use your iPhone rant, first remember that the iPhone is sold to completely average people, therefore, a simple UI is the primary requirement. (In other words the "dumbwagon" must be the default.) Furthermore, it should be restricted so that Joe Average can't accidentally screw it up to the point where it's impossible for him to recover to the dumbwagon state. Beyond that, however, everything else should be possible - there should be advanced configurations, user scripting, compilers, all that stuff that makes a computer do what I want. (And that's why I hate Apple.)

      --
      John
    53. Re:To quote Einstein by Anonymous Coward · · Score: 0

      Cyclomatic complexity has a direct correlation with readability. Cyclomatic complexity can be measured by a machine. Cyclomatic complexity is usually defined over methods. I would say that any method that has 35 different paths through it could very probably be rewritten to be clearer. The notion that a switch statement with 35 cases is somehow good code is very questionable. If I ran into a switch statement with 35 different cases I would think that is needs examination which is the point of complexity measurements. Some design geeks think that a presence of a switch statement is a good indication that your code could be clearer.

    54. Re:To quote Einstein by Anonymous Coward · · Score: 0

      But you can see the obsession geeks (who are the developers) have with this here.

      People here slag "walled gardens," when in reality - a vast majority of consumers don't give a shit, and - even with the ability to do so - will never install apps on their phone from a 'non-approved' source, and will never root or jailbreak their phone.

      The developers who obsess about ultimate flexibility and customizability are the ones writing the code, and without strong project management keeping them focused, these devs will often build the software they would want - doesn't matter if only one in a million people will need to edit a particular option: "one person possibly needing it at some point in time? By god it needs a checkbox!"

    55. Re:To quote Einstein by Mitchell314 · · Score: 1

      But . . . but what if you need to reconfigure the value of pi during runtime?!

      --
      I read TFA and all I got was this lousy cookie
    56. Re:To quote Einstein by triffid_98 · · Score: 1

      "Help me...Kirk!" -- Abraham Lincoln

    57. Re:To quote Einstein by Patch86 · · Score: 1

      In any larger development house, that is the job of the Analysts. They should be doing their job and finding out what use cases need catering for. The developer then just needs to build it. If the developers spots something that they think has been missed, they should get their Analysts back on it to verify whether this is actually a "missed requirement", or is in fact "not a requirement". If you are doing double duty as coder and Analyst, it's your job to do this leg work and find out what you need to be coding for.

      Obviously developers are good at spotting specific fallover and marginal cases that nobody else has, by the nature of the beast, and that is good. But too many developers get into "the zone" and think they're building some magnum opus of wonderful complexity, when all they've been asked for is something for parsing XML forms...

    58. Re:To quote Einstein by Anonymous Coward · · Score: 1

      Yes. Reminds me of the time (years ago, hopefully the code has changed since) when I was trying to learn to use libpng, but found it difficult because of retarded shit, like the ability of the library to be compatible with 17-bit and 19-bit and 23-bit computer systems, as well as many other conceivable yet non-existent architectures. I eventually gave up and found some public domain code that could do what I needed.

      At some point, it's easier to simply go back and fix the code later if some bizarre case comes up than it is to handle every conceivable case from the beginning. Not only in the time it takes you to develop the software to begin with, but in the time it takes everyone else to deal with the added complexity.

    59. Re:To quote Einstein by Ash-Fox · · Score: 2

      Yes, but this should be done prior to code writing.

      Considering how often clients will sign off on something and then double back on what they signed off on, and ask for changes and sign off on those new changes which then invalidate some requirements that were previously implemented but because they were signed off, it's a requirement... I think expecting these situations to be completely resolved beforehand is wishful thinking.

      Me: "Did you ask if X would ever need to be reconfigured?"

      Developer: "Of course! And the client said that sure, if I could make it configurable, go ahead and do so"

      Why is the developer handling requirements and not someone dedicated to dealing with business logic? Your developer should be talking to your project's business analyst about these things, not the client. Your projects don't sound very well setup, you're clearly missing vital controls. No wonder why you have problems with developers.

      --
      Change is certain; progress is not obligatory.
    60. Re:To quote Einstein by Anonymous Coward · · Score: 0

      Always check every return code and install handlers for all possible exception when writing production code. No excuses. No "it makes the code ugly and harder to read". Just do it.

    61. Re:To quote Einstein by KingMotley · · Score: 2

      Is this part of Agile Programming or something? Write the most incomplete code you can get away with because it isn't in the spec?

      Yes. It's part of TDD, where the coder is supposed to write the absolutely smallest set of code that passes said test.

    62. Re:To quote Einstein by Anonymous Coward · · Score: 0

      "Well, it depends entirely on how hot your sister is." --Jesus

    63. Re:To quote Einstein by Anonymous Coward · · Score: 0

      Clearly, not taking his own advice here...

      First good laugh of the day! And my virgin post to /.

    64. Re:To quote Einstein by St.Creed · · Score: 1

      In Agile development this is called "building inventory" and it's a net cost, not an asset waiting to be used. It takes a while before people understand the whole "inventory == cost" concept but once they do, it really helps to avoid this scenario.

      --
      Therefore, by the (faulty) logic you're using, you're just a cow with a keyboard - osu-neko (2604)
    65. Re:To quote Einstein by St.Creed · · Score: 1

      Why is the developer handling requirements and not someone dedicated to dealing with business logic? Your developer should be talking to your project's business analyst about these things, not the client. Your projects don't sound very well setup, you're clearly missing vital controls. No wonder why you have problems with developers.

      Yes, don't let any of the folks doing any work talk to a user for crying out loud! Make sure to insulate them by as many unemployed cousins as possible, enabling you to make a tidy profit, and preventing the client from having to talk to those dreadful nerds. A win-win all around.

      Do you work for Accenture by any chance? Because you sound familiar...

      --
      Therefore, by the (faulty) logic you're using, you're just a cow with a keyboard - osu-neko (2604)
    66. Re:To quote Einstein by aztracker1 · · Score: 2

      I find that this is most often the case when people will use "Enterprise Design Patterns" for small projects that do not inherently need them. Much of the time this makes things more complex with no real benefit.

      --
      Michael J. Ryan - tracker1.info
    67. Re:To quote Einstein by St.Creed · · Score: 1

      I don't think you use "use case" entirely in the way I normally use it. A use case is what it says: something where someone or something uses the code to achieve some desired result. Error handling is just a part of it to make sure you actually complete the use case.

      Logging, auditing and security are all non-functional requirements. You can find whole libraries on this but the basics are pretty simple. Note: non-functional requirements. They're not in any use case.

      As for checking the returns of any function: I completely agree! Just give your co-worker a good kick in the behind and tell him it's from me. But it is just one effing non-functional requirement at best (and usually not even that, but it's just part of the coding standards), not a use case.

      --
      Therefore, by the (faulty) logic you're using, you're just a cow with a keyboard - osu-neko (2604)
    68. Re:To quote Einstein by St.Creed · · Score: 1

      Just a few requirements from last week:

      REQ.1: A report will be provided with an overview of the number of incoming, delivered and processing cases.
      REQ.2: A case will be counted as "incoming" when the creation_date is filled with a valid date(*).
      REQ.3: A case will be counted as "delivered" when the status = "Final" and the delivery_date is filled with a valid date.
      REQ.4: A case will be counted as "processing" when REQ1. has been satisfied but REQ.2 has not.
      REQ.5: All cases can be counted per "purchasing organization", "business unit" and "order month".
      REQ.6: A purchasing organization has a level called "organization', which consists of the full name of the organization (ORG.FULL_NAME).
      etc.

      Non-functional requirements deal with exceptions, missing values, auditing, logging, security, backup & recovery, scheduling, etc. etc.

      While the set above is not complete, it does show a bit of standard requirements.

      (*) I'm sure you can nitpick about edge cases where the database suddenly gets corrupt. We ignore that explicitly.

      In the software I wrote the specs for (last year) we had requirements like "The MEDICATION field has to hold a valid value that is present in table X, or the entire record will be referred to the basket for manual processing". It really doesn't need to be more complex than that, for a lot of cases.

      --
      Therefore, by the (faulty) logic you're using, you're just a cow with a keyboard - osu-neko (2604)
    69. Re:To quote Einstein by Anonymous Coward · · Score: 0

      Talking to customers should be done, but new requirements should be signed off on before they are actually implemented....

      This is especially true when you have new, or just stupid, project-managers etc... They create a document where they list feature X, Y and Z.
      When the developer looks at the specification they see that X, Y and Z will be hard to implement and will cause a bad user-experience. In this case the developer should have direct contact with the customer, but before development start with the much better option Q it should be signed off by both the customer and project-manager. It might be that Q takes shorter or longer time, but for the customer to get constant feedback from the people that is actually writing and testing the software is always good...

      Also in all those agile development processes that are being implemented everywhere there should be constant feedback between developer and customer... But yes, a project-manager should be *involved* when changing anything in the spec..

    70. Re:To quote Einstein by Anonymous Coward · · Score: 0

      I have seen agile development, scrum to be more precise, being implemented in both large and small firms... It works for some type of development but it fails radically in lots of others...

      And the reason why it continues for so long is exactly that argument... 'It takes time to get into the new way of working'.....

      Just had to rant a bit... But today was a perfect example... I have a number of tasks that needs to be done during this sprint... But i'm the only one with knowledge about some parts so i have been constantly interrupted every 20-40 minutes during the whole day, and that is probably not going to change...

    71. Re:To quote Einstein by Anonymous Coward · · Score: 0

      I noticed many years ago that once I started writing object-oriented code, switch statements became very, very rare for me. Looking at other people's Objective-C code, I have seen a few cases where someone wrote a chain of if-then-else statements where they were testing for [self class] == some particular class. Made me cringe.

    72. Re:To quote Einstein by Anonymous Coward · · Score: 0

      Or you could just fire all the management that knows nothing about writing code and use the saved time from bogus meetings, etc. to actually do good work for the customer.

    73. Re:To quote Einstein by Anonymous Coward · · Score: 0

      I would say... write to maximize the chance of data-restoration (automatic or not) when things go bad...

      If you have to replay some things at restart then no worry.. Just as long as nothing important is lost...

      Also for embedded systems... The thing that should be tested, tested, tested and then tested a few more times is the sw-upgrade.... cause if that fails you are screwed when the device is in the field...

    74. Re:To quote Einstein by Belial6 · · Score: 2

      That is only if you look at the problem from strictly a developer's point of view. In many environments, new applications mean greater accountability, and often increased workload generated by the software preventing work tasks from getting 'lost'. From a manager's point of view, the greater accountability is good thing, and the employees should have been doing all of the tasks all along. After all, it is hard to argue with a manager that "If we use this software, we will have to do our jobs completely.". The argument that "We have not been doing our jobs completely because we do not have the staff to do the job completely." gets heard and acted on as if it is only "We have not been doing our jobs completely.".

      Thus, the users who are now being put in, quite frequently, the role of completing impossible tasks are going to be hostile to the introduction of the software. Whether the company is run well or badly, they likely have some of the more trusted users assigned to acceptance testing. These users can have a vested interest in exploiting even the slightest ambiguity in the spec. If they can find anything that could be construed as being incorrect, they will happily send you back for another round of updates. This can be dragged out for months before management decides to pull the plug on the project completely.

      If you are an in house developer, you have just wasted a huge amount of time, and your project has been a drain on the company. If you are an outside developer, you now have to take a loss on payment, or call in the lawyers. None of these options are good.

      Conversely, a few configurable items can nip this behavior in the bud. There are only so many times that a hostile user can declare an application unusable due to a button name preference, or icon color when each declaration is responded to with a "No problem. You are just looking at the default. It is a customer configurable feature. Just click on settings and there is a field to set it to whatever you want.". After the 3rd or 4th time this happens, the ploy starts to wear thin. Eventually management steps in to put an end to it.

      Just as both simplicity and complexity can be taken too far, so can configuration. Counting on customers to always know or understand when configurability makes sense is a recipe for disaster.

    75. Re:To quote Einstein by Anonymous Coward · · Score: 0

      If you are reusing a code-base for multiple projects designing the code to be able to support feature Y, Z, Y, U, V is good practice...

    76. Re:To quote Einstein by mpeskett · · Score: 1

      I think it's quite well in the spirit of the thing to paraphase that as "Everything should be made as simple as possible, but not simpler"

      Can we attribute quotes to Meta-Einstein?

    77. Re:To quote Einstein by Belial6 · · Score: 1

      The flip side of that is that sometimes adding the functionality makes the functionality no longer a requirement. I have had several clients that would spend months calling for labels on buttons to be changed. It would be "Submit", then "Save", "Save and Close", "Save Document", "Save Ticket", "Submit Ticket", back to "Submit" only to start the pattern over again. Each of these would require setting up a meeting and demoing the entire software package to bring the new players up to speed on the application only to have a button title complaint that has the users declaring it impossible for them to continue acceptability testing on the application until the label is "fixed".

      The first year I worked with one of my current clients, this was standard operating procedure for the company. They went through contractors like sun flower seeds. The solution was to write a function that scanned the code for button labels and make them available in a configuration screen. Not only did this solve the problem, but the customer never used the feature. Amazingly, as soon as the button labels became customer configurable, the default labels became acceptable. Over the course of 12 years working with this company and dozens of applications, only 2 button labels have ever been changed from the default.

      From an audit perspective, making button labels configurable would look like insane complexity that was a waste of time and money. When the company culture and employee behavior that no one want's to admit exists are taken into account, it starts making a lot more sense. That "unnecessary" code complexity saved the company $100s of thousands of dollars while simultaneously improving user acceptance.

    78. Re:To quote Einstein by pakar · · Score: 1

      One line specification of something like that is not really real world so adding a few things...

      - What about during initialization of the frame-buffer that will take 50ms? Is it ok to open screen and clear and set pixel or does the framebuffer have to be initialized with the specified pixel before output is activated?

      - We have 3 hardware layers where layer 2 has this pixel and layer 3 displays error message. Error message X is defined as fullscreen and during error the application is paused. Should the error-screen set alpha on pixel 0,0 to show it or do we not have to conform to this since the application is in pause-mode?

      - Hardware requires alpha value to be set. Layer one will show video. Spec also says that all graphics should have a alpha of 200, does this include this pixel? Is it 128,128,128 when having a black layer 1 or is it 128,128,128 when having a white layer 1 in that case?

      Even a dead-simple specification like that can be broken down so much when adding a few more requirements that makes it impossible for anyone to think of all corner-cases.. And if they would have written a spec to that degree of accuracy no developer would be able read the whole specification and remember everything during development.
      You usually also divide work up on multiple developers where each developer gets a part of the specification that he should implement, but that developer only sees his part and don't want or have time to read and understand the full spec of the software.

      For each overlapping feature you have an exponential growth of sub-feature-specifications that would have to be written to be able to handle all corner-cases...

    79. Re:To quote Einstein by The+Evil+Atheist · · Score: 1

      With the assumption that the test is complete enough to test things that aren't just in the spec, like errors. Most Agilers seem to think a test is about whether something works. It's about whether it can survive attempts to break it.

      --
      Those who do not learn from commit history are doomed to regress it.
    80. Re:To quote Einstein by larsbars · · Score: 1

      Ok, say it shorter, wise guy.

    81. Re:To quote Einstein by norpy · · Score: 1

      Configurable parameters are way cheaper to fix *in the field* than a hardcoded value, even if they are undocumented and require reading the code to find. Set them to the sane default and ignore them until you need to repackaging, testing and deploying an application is EXPENSIVE.
      Changing a configuration item in a backup environment and running a few sanity checks is relatively cheap in comparison.

      If you aren't using a platform that makes configuration of everything that is not a nailed-to-the-floor constant simple then you should probably look into spending a few hours building yourself a small framework for doing so and reusing it on every project going forwards.
      Even if it's just a simple key/value store added to your model and read out of your database at start-up and accessible anywhere in your application.

    82. Re:To quote Einstein by Anonymous Coward · · Score: 0

      Yes. It's part of TDD, where the coder is supposed to write the absolutely smallest set of code that passes said test.

      And where in TDD does it say to only write that one test, and not write additional tests that would handle the other paths and corner cases?

    83. Re:To quote Einstein by dfghjk · · Score: 1

      Sounds like neither of you are worth having. Your co-worker for never writing anything of quality and you for never writing anything at all.

    84. Re:To quote Einstein by nmb3000 · · Score: 1

      I can't believe you forgot Oscar Wilde.

      Kids these days are a bunch of disrespecting dicks. -- Oscar Wilde

      --
      "What do you despise? By this are you truly known." --Princess Irulan, Manual of Muad'Dib
      /)
    85. Re:To quote Einstein by Anonymous Coward · · Score: 0

      I've been slinging code for 20 years on just about every type of platform... I can ASSURE you that your insecurity, and more importantly your REALLY bad solution to it (trying to code for everything imaginable) is the source of a LOT of bugs and code bloat.

      The whole thing is a separation of concerns issue. Rather than littering your code with every conceivable type of exception that could possibly happen, you need to learn about TDD. TDD combined with CI separates your app into two pieces. One piece does what the user wants (what you today consider "the app"), and the other piece proves that the first one is working in any conceivable situation. If you layer TDD, CI, and AATDD (functional testing), you end up with lean code that does only what it needs to do, but you still have all the security/quality you're trying to achieve.... in fact you've probably got HIGHER quality.

      Now, get off my lawn.

    86. Re:To quote Einstein by PuZZleDucK · · Score: 1

      But . . . but what if you need to reconfigure the value of pi during runtime?!

      or 5?

      --
      Can a person program a new solution to a problem? Why should anyone be able to stop such a thing? -Richard Stallman
    87. Re:To quote Einstein by Nefarious+Wheel · · Score: 1

      I've done that. Ancient General Automation GA-16/440 minicomputer using their native Fortran 66.

      I'd set a constant = 5, then inadvertently used the constant as the result variable in an expression, and, sure enough, it was 5 that I'd redefined. Incredible whacked-out results from then on.

      Took one hell of a long time to debug.

      I think that bug, and all the accumulated strangeness of writing for that platform, is why I feel relieved that I don't write software any more.

      --
      Do not mock my vision of impractical footwear
    88. Re:To quote Einstein by burning-toast · · Score: 1

      And yet, no more redundant than necessary.

      - Toast

    89. Re:To quote Einstein by shentino · · Score: 1

      Keeping a customer happy often depends on making maintainable software, which indirectly impacts the complexity issue.

      You can be a neatness zealot, or a hairy coder, but at the end of the day, if you (or your co-workers) cannot maintain the codebase the way the customer wants it, you're shooting yourself in the foot if you make it hard for yourself.

    90. Re:To quote Einstein by shentino · · Score: 1

      I both have said and not said many things, but you will never know which is which unless you listen.

    91. Re:To quote Einstein by mwvdlee · · Score: 1

      Not all customers are smart enough to know to ask for everything.

      Worse still, no customer is smart enough to ask for error handling, fringe cases, ACID compliance or any of those other things.
      Try explaining 80%/20% to a customer; they will think you are wasting 80% of their budget on rarely used features and very unlikely situations.

      --
      Slashdot social media options: AIM, ICQ, Yahoo, Jabber and Mobile Text. Why no MySpace?
    92. Re:To quote Einstein by Anonymous Coward · · Score: 0

      The definition of a myth is objective; it has nothing to do with your perspective.

    93. Re:To quote Einstein by Ash-Fox · · Score: 1

      Yes, don't let any of the folks doing any work talk to a user for crying out loud!

      There is no issue with talking to the user, but anything that involves changing requirements should involve the business analyst, get the requirement written up and signed off. That includes clarifications, otherwise you're putting your project at a higher risk of not delivering what the client wants as well as a creating risks where the client goes back on their word and then claims this wasn't part of the signed off specification.

      Do you work for Accenture by any chance?

      Never worked for or with Accenture. But I have been on enough projects that involved problems created by misunderstandings and lack of procedure.

      --
      Change is certain; progress is not obligatory.
    94. Re:To quote Einstein by Ash-Fox · · Score: 1

      Talking to customers should be done

      I'm not saying the developers can't talk to the client, but when it comes to requirements, the business analyst should be there and should be the one that gets the sign off. The developer shouldn't the focal point of contact in these matters because otherwise the client will end up using the developer's time to manage requirements instead of the analyst, this detracts from development time and inevitably will cause schedules to slip. It also causes undue pressure on the developer, because the developer is the one that has to develop the code, inevitably they will get pushed into a corner where they will accept something as a requirement (human nature unfortunately) in order to deliver something on schedule.

      --
      Change is certain; progress is not obligatory.
    95. Re:To quote Einstein by Xest · · Score: 1

      "Yes, but this should be done prior to code writing."

      Wrong, wrong, wrong.

      For projects of any reasonable size, that may even take as little as 6 months the reality is that the client may not even know what the requirements will be in 6 months time.

      An anecdote I referred to in a previous discussion on a similar topic is a 18 month project I finished off last year. When the client was gathering initial requirements they wanted Blackberry support and SMS functionality, the iPad didn't even exist when they were gathering requirements, it wasn't long into the project that we actually started to work on it that SMS became less of an issue and Blackberry became a low priority support target instead preferring to have full Android/iOS support and support for dispatch to a notification app on those platforms. Business needs agility because in the real world business realities change quickly, sometimes in just a matter of a couple of weeks or in rare cases even days and this becomes ever more true depending on how competitive an industry your client is in.

      Luckily we'd already abstracted notification dispatch so writing a dispatcher class for a mobile app they were to developing separately in place of SMS dispatch was trivial and no more expensive for them and similarly because we worked in a flexible manner it was no big deal dropping Blackberry support in favour of Android/iOS browser support on the web frontend.

      Similarly on the same project we built scope for future flexibility into the database schema creating tables that weren't immediately needed but meant no refactoring needed for future work. As I left the project the client came back asking for exactly what I suspected to be added in and so rather than being a couple of week long refactoring job followed by implementation it was largely just implementation such that we could charge the client less than we'd otherwise have needed to but still charge a little more to increase our margins.

      This is why you write and design code with added complexity, because the added complexity is never so cost inefficient (well unless you take it too far to the extreme) that it's not worth it. Part of being a good developer is being able to see where the client is likely to want to go in the future and yes, that means writing code that is not immediately useful but will be in the future.

      I've always been able to deliver projects with really high profit margins (60% - 70%+) and I couldn't do this if I hadn't designed flexible architectures. The amount of refactoring required or the amount of pissed off customers at our refusal to accept the inevitability of change if we just set things in stone from the outset and said no changes, or charged for said refactoring would be massively detrimental to our business.

      There's obviously balance to be drawn, your example seems a little extreme but being a good developer is absolutely about being able to foresee where your client needs will change and developing for that from the outset. It's the only way you can build a good relationship with customers and also make sure the inevitability of change will benefit you and the customer, not cost you both with wasted unnecessary refactoring time due to inflexible design.

      I think a lot of Slashdot devs are either inexperienced or have only done internal dev, because the reality of working with clients and understanding as a result why change happens and why it's inevitable would soon put stop to some of the "It should be specced from the outset and never change" comments because you just cannot build good relationships with customers and hence cannot make a healthy profit across projects or even per-project that way. That attitude is a relic of internal development departments who feel they get to mandate to their colleagues what they're getting rather than bothering to listen to what they want and adapt as realisations change - you shouldn't even work like that internally if you want to work in a healthy business but you definitely can't work like

    96. Re:To quote Einstein by Xest · · Score: 1

      Please ignore your overrated moderation, Slashdot has gone downhill and the amount of amateur whiners that can't get jobs because they're actually shit rather than whatever excuse they use (H1-B, ageism, whatever) is grossly higher than those who actually are in jobs and have a clue what they're on about.

      It's scary how many people here don't get that change is an inevitable fact of software development, it really shows how inexperienced and incompetent so many people on Slashdot nowadays are so it's no wonder that so many of them whine about being unemployed for what ever reason - it's not surprising when they're that shit.

    97. Re:To quote Einstein by Anonymous Coward · · Score: 0

      No, I'm pretty sure I've seen you before, Mr. Coward.

    98. Re:To quote Einstein by dlingman · · Score: 1

      Coordinate system? Is 0,0 in the centre of the screen, lower left, upper left etc.

    99. Re:To quote Einstein by Anonymous Coward · · Score: 0

      That's why I hard-code everything. I have a version compiled for dev, test, and production to manage the environment. After all, the customer didn't ask for it to be configurable across environments. And when some team lead asks my why I hard-coded everything, I just give him a blank stare.

    100. Re:To quote Einstein by Quirkz · · Score: 1

      This seems deeply insightful. I'd give you mod points if I had 'em.

    101. Re:To quote Einstein by lgw · · Score: 1

      No, it's really, really not. It's far cheaper on average to re-write on those cases where the imaginary use cases become real, than to write code speculatively - not least because you usually get imaginary use cases wrong and have to re-write the code anyway.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    102. Re:To quote Einstein by lgw · · Score: 1

      TDD moves the burden of writing good code to the test. In any case unit tests should check that the code fails the right way for every corner case you can think of, even when you're not doing TDD, so it's not that odd of a concept.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    103. Re:To quote Einstein by lgw · · Score: 1

      One of the best things to happen to C was the standard types header in C99, which sort of accidentally imposed the assumption that all computers have 8-bit bytes and 2s-compliment negative numbers on the standard. What a relief!

      --
      Socialism: a lie told by totalitarians and believed by fools.
    104. Re:To quote Einstein by Anonymous Coward · · Score: 0

      In the words of Albert Einstein: "I never said most of the things I said."

      This is Yogi Berra's quote.

    105. Re:To quote Einstein by sje397 · · Score: 1

      "Yes, but this should be done prior to code writing." Can't be done.

    106. Re:To quote Einstein by PuZZleDucK · · Score: 1

      Took one hell of a long time to debug.

      Haha, realy?

      --
      Can a person program a new solution to a problem? Why should anyone be able to stop such a thing? -Richard Stallman
    107. Re:To quote Einstein by Zalbik · · Score: 1

      True...I was more ranting in agreement with the original comment of "Stop tripling the size of your code for use-cases that no one has asked for, people!" (though perhaps I should have responded to that post...)

      Yes, sometimes there definitely are corner-cases that require complexity in code. My issue is that too often I find that programmers attempt to "program themselves out of a corner" when they come to these corner cases, rather than sitting down with the customer, explaining the issue, and understanding the solution prior to coding. This is especially annoying in agile projects where the customer has to invest significant amounts of time in the project in part to prevent this sort of thing from happening.

      Yeah, Version 2 is a bitch. It's also why I often think maintenance programmers have a much harder (and in some ways more interesting) job than original developers of systems, even though (in my experience) it tends to be the "rock stars" who get the new development projects.

      I really don't understand Dobb's point. He seems to be arguing that agile developers with an "obsessive reverence for simplicity" insist that code be made simpler than it could possibly be written. I've never found that to be the case. Obviously if you are dealing with a complex problem domain, it's gonna have complicated code. However, I have frequently seen the case when code was more complex than it needed to be due to feature creep / gold plating / poor communication with the customer / bad coding skills / poor understanding of the language or tools / etc.

      He seems to argue the opposite....that most complaints of complexity are around code that needs to be complex. I dunno...different experiences possibly....

    108. Re:To quote Einstein by vilanye · · Score: 1

      Here is a slightly different take on it: 'Simplicity is prerequisite for reliability.' Edsger Dijkstra

  2. Meh by Anrego · · Score: 5, Insightful

    Interesting article, but this seems an issue of a very pedantic interpretation of a common idiom.

    When I (or I suspect most) whine about pointlessly complex code, it's just that. Code that is more complex than is reasonable for the problem. No one expects a simple solution for a challanging problem. It's an overly complex solution to a simple problem which we complain about...

    1. Re:Meh by Anonymous Coward · · Score: 0

      True but you can't get up on your high horse over that can you?

    2. Re:Meh by Anonymous Coward · · Score: 2, Insightful

      I think Dr. Dobb's stopped being relevant oh like 10 years ago. Its like a total kids magazine now, nothing like it was years ago. Most articles in it are unreadable.

    3. Re:Meh by Anonymous Coward · · Score: 0

      So I take it you're a subscriber? You certainly write like you're 12 years old.

    4. Re:Meh by Anonymous Coward · · Score: 0

      One of the programmers I work with complains when you use more than 1 function to do a job. Even if it means writing a 20 page function. His code is unmaintainable because you can't change even a tiny part of it without breaking something 3 pages down. He cries that my code is too complex because I break things down into small simple functions and multiple files and build complex behaviors out of them so he has to swap between files.

      He used to work on IE at Microsoft, so that might tell you something.

    5. Re:Meh by Anonymous Coward · · Score: 0

      You're kidding right? When I come into a new job and need to re-write some god awful code, it's common to reduce 3000 lines to 400. It become easier to understand, smaller, more maintainable and more resource-efficient.

      As far as I'm concerned, the simple solution which solves the same problem is worthy of getting on my high horse. I'm quite proud of fixing code in this way. I'm not proud of writing needlessly complex shit. Only idiots use "lines of code" as a metric.

    6. Re:Meh by spiffmastercow · · Score: 2

      One of the programmers I work with complains when you use more than 1 function to do a job. Even if it means writing a 20 page function. His code is unmaintainable because you can't change even a tiny part of it without breaking something 3 pages down. He cries that my code is too complex because I break things down into small simple functions and multiple files and build complex behaviors out of them so he has to swap between files.

      He used to work on IE at Microsoft, so that might tell you something.

      Do you re-use your functions, or do they only exist to break apart a single operation into smaller blocks? If it's the latter, then he may have a good point.

    7. Re:Meh by interval1066 · · Score: 1

      My thought exactly. Binstock is certainly correct, but the tone of the article is as if there is a world-wide problem that needs to be addressed. I don't think so. I think he feels the need to qualify a programmatically philosophical point that everyone implicately understands already. For example, I've never had a manager look at my project and say "It has to be simpler!", meanwhile I'm always questioning my code and looking for stuff I can remove. When I get to a point where I simply can't, I move on.

      --
      Python: 'And then suddenly you have a language which says "we're all stuck with whatever the whiniest coder wants".'
    8. Re:Meh by rwv · · Score: 2

      It wasn't until the mention of Cyclomatic Complexity that I understood what the summary was saying. It boils down to writing individual functions logically with as many if/else/while/for/switch branches as you need. Oftentimes, breaking up code into multiple functions to satisfy some arbitrary Cyclomatic "Complexity" coding standard makes it MORE COMPLEX. On the other hand, Cyclomatic Complexity can be used to find spaghetti code that would make a good project for refactoring. At the end of the day... human analysis figures out what is simple vs. complex. It's impossible to know how complex a piece of software is with code metrics alone.

    9. Re:Meh by phantomfive · · Score: 1

      For example, I've never had a manager look at my project and say "It has to be simpler!",

      He probably did have a manager (or some coworkers) who did say that, which is why he was motivated enough to write a rant on the topic.

      --
      "First they came for the slanderers and i said nothing."
    10. Re:Meh by Anonymous Coward · · Score: 0

      Umm no retard, that implies I was and dropped it. Think my friend, you write like your 60 Holmes.

    11. Re:Meh by Anonymous Coward · · Score: 0

      No, he wouldn't have a good point. Breaking even a single operation into smaller blocks it a good thing, if it spans hundreds of lines.

    12. Re:Meh by ewibble · · Score: 2

      Reuse, and breaking a problem in simpler logical blocks are both valid reasons to use functions, the latter helps in understandability and limits scope since you can more clearly determine what the inputs and outputs , and intent of a function is (as long as you name it right). You can also read the main function easier.
      ...
      int id = findIndex(name,table);
      ...

      reads much easier than:
      ...
      int id = -1;
      for (int i = 0; i < table.size; i++) {
            if (strcmp(name,table.data[i].name) == 0) {
                    id = i;
                    break;
            }
      }

      ...

    13. Re:Meh by Anonymous Coward · · Score: 0

      I completely agree and would like to add, that developing simple solutions to what appear to be complex and challenging problems, is the next rung up in the hierarchy. It is a rare skill, but it does exist.

      There are those who can :

      1) not solve simple problems
      2) can solve simple problems, in complex ways
      3) can solve simple problems, in simple ways
      4) can solve complex problems, in complex ways
      5) can solve complex problems, in simple ways

      In increasing order of difficulty

    14. Re:Meh by Darinbob · · Score: 1

      A lot of code is complex because it is not well understood. It's like going on a trip but not knowing how to get there. So you start driving and a few hours later you make a course correction, then an hour later you backtrack, and so on. At the end of the trip you've got a very convoluted route. Yes, you got to the end but it's complex. Whereas the simple way is to figure out how to get there first, know where the roads go, and keep the destination in mind. Sometimes it's hard prep work like looking at all the maps, but sometimes its experience too like knowing which roads tend to have the most traffic.

      Simple code can be very hard because you have to understand what you're doing, understand the problem that's being solved, and understand the tools that you have available. Complex code can be easy because you just start coding as soon as possible and make course corrections along the way.

    15. Re:Meh by Intropy · · Score: 1

      20 page function? IE? Does his code look like this?

      if (foo)
      {
          if (bar)
          {
              if (baz)
              {
                  if (qux)
                  {
                      if (grault)
                      {
                          i += 10;
                          DoCorge(i,
                                  bar,
                                  qux,
                                  fred);
                          // All my
                          // horizontal
                          // space got
                          // eaten by
                          // "triangular"
                          // style :-(
      ...
       

    16. Re:Meh by spiffmastercow · · Score: 1

      No, he wouldn't have a good point. Breaking even a single operation into smaller blocks it a good thing, if it spans hundreds of lines.

      Generally speaking, yes. But you do that by identifying code re-use points and separations of concerns. Not by arbitrarily breaking down an irreducibly complex algorithm into complex subroutines that only exist to move code off to separate locations. My guess is that, if you're dealing with a function that is hundreds of lines long, you missed out on a whole lot of points for code reuse.

    17. Re:Meh by Darinbob · · Score: 1

      Complexity often comes from having lots of incremental changes designed to fix a small problem in a short amount of time. Ie, add a global variable, add more function parameters, rely on a side effect, special cases for just one feature for one customer. After a few years code that used to be simple can become a complicated mess.

    18. Re:Meh by T.E.D. · · Score: 4, Insightful

      Do you re-use your functions, or do they only exist to break apart a single operation into smaller blocks? If it's the latter, then he may have a good point

      I disagree, strongly. Breaking a large routine into smaller ones abstracts away what those smaller routines are doing. It puts a boundry around their interaction with the rest of the code, and puts their code away somewhere that I don't have to worry about, unless there's some reason I want/need to know the details of how that routine accomplishes what it does.

      If you put it all flat into one big routine, I have to read and grok everything in that routine, if only to reassure myself that none of it has interactions with the one area I care about.

      We actually have terms for this stuff: Cohesion and Coupling. Cohesion in particular is an important concept here.

      I find it amusing that the author's big example is Aho's parsers. Parsers are one of those special cases, as lexical analysis is a problem that is generally best solved by state-machines. I've tried for years, and really there aren't a lot of good ways to code lexer state machines that aren't either way slower than the typcial implementations, or a web of control flow that looks like a huge mess to those of us reared on structured programming. It isn't talked about much, but lexers (and some parsers) unashamedly make use of goto statements as their core braching mechanisim. Using Aho's awk parsing code as an example of why "clean" code isn't always desirable is like using the US Marines as an example of why killing people is often a good option for solving disputes. Perhaps its true in a technical sense, but its really crappy advice to be giving the general public.

    19. Re:Meh by spiffmastercow · · Score: 2

      Reuse, and breaking a problem in simpler logical blocks are both valid reasons to use functions, the latter helps in understandability and limits scope since you can more clearly determine what the inputs and outputs , and intent of a function is (as long as you name it right). You can also read the main function easier. ... int id = findIndex(name,table); ... reads much easier than: ... int id = -1; for (int i = 0; i < table.size; i++) { if (strcmp(name,table.data[i].name) == 0) { id = i; break; } }

      ...

      My guess is you're going to use findIndex more than once in your programming career though, making it a prime candidate for function from code reuse standpoint. I consider this a poor example. It's hard to find a good counter-example, because there have been very, very few times in my career where I've written code that I couldn't reuse. In my experience moving code off to a separate function for no other reason than to clarify the code only helps clarify the code for the initial author, not for those who have to dig through all of his nested one-use functions to figure out what's actually going on.

      I will concede that separation of concerns is a good reason to break apart single-use operations. But not arbitrarily based on code size.

    20. Re:Meh by Anonymous Coward · · Score: 0

      A lot of code is complex because it is not well understood. It's like going on a trip but not knowing how to get there. So you start driving and a few hours later you make a course correction, then an hour later you backtrack, and so on. At the end of the trip you've got a very convoluted route. Yes, you got to the end but it's complex. Whereas the simple way is to figure out how to get there first, know where the roads go, and keep the destination in mind. Sometimes it's hard prep work like looking at all the maps, but sometimes its experience too like knowing which roads tend to have the most traffic.

      Simple code can be very hard because you have to understand what you're doing, understand the problem that's being solved, and understand the tools that you have available. Complex code can be easy because you just start coding as soon as possible and make course corrections along the way.

      I'm sorry, your metaphor is unacceptable. We all have GPS and don't know what maps are unless you mean the Google Maps application. Please think of a more appropriate metaphor... you insensitive clod!

    21. Re:Meh by ebno-10db · · Score: 2

      Breaking even a single operation into smaller blocks it a good thing, if it spans hundreds of lines.

      I miss nested functions - they were very useful for just that sort of thing. It also clarifies that nested function g() exists only to implement something in enclosing function f(), which is often the case when breaking thinks up for clarity rather than trying to write reusable functions. Since a nested function can access the locals of its enclosing function, it also often avoids having to pass very long argument lists.

      Nested functions were a standard feature of Algol family languages, but unfortunately died w/ C (though gcc supports nested functions as an extension). These days many people seem unaware that there even is such a thing as nested functions.

    22. Re:Meh by spiffmastercow · · Score: 2

      Breaking even a single operation into smaller blocks it a good thing, if it spans hundreds of lines.

      I miss nested functions - they were very useful for just that sort of thing. It also clarifies that nested function g() exists only to implement something in enclosing function f(), which is often the case when breaking thinks up for clarity rather than trying to write reusable functions. Since a nested function can access the locals of its enclosing function, it also often avoids having to pass very long argument lists.

      Nested functions were a standard feature of Algol family languages, but unfortunately died w/ C (though gcc supports nested functions as an extension). These days many people seem unaware that there even is such a thing as nested functions.

      Nested functions are quite nice, and are actually supported by most higher level languages in common use these days. It's a much more appropriate way to break up code than putting bits and pieces all over the place just to reduce the size of a single code block.

    23. Re:Meh by gmueckl · · Score: 1

      Most higher level languages in common use? C, C++, Java don't have them. What other language is in "common use" these days? PHP?

      --
      http://www.moonlight3d.eu/
    24. Re:Meh by spiffmastercow · · Score: 2

      Most higher level languages in common use? C, C++, Java don't have them. What other language is in "common use" these days? PHP?

      Actually, the latest C++ and Java implementations do support it, as do C#, VB, Lisp variants, Python, and Scala, and most any pure functional language. Anything that supports closures supports this to some degree (the readability of the solution varies, however).

    25. Re:Meh by Anonymous Coward · · Score: 0

      You're not helping your case any with the "angsty tween" tenor you've got there.

    26. Re:Meh by MrChips · · Score: 2

      Do you re-use your functions, or do they only exist to break apart a single operation into smaller blocks? If it's the latter, then he may have a good point

      I disagree, strongly. Breaking a large routine into smaller ones abstracts away what those smaller routines are doing. It puts a boundry around their interaction with the rest of the code, and puts their code away somewhere that I don't have to worry about, unless there's some reason I want/need to know the details of how that routine accomplishes what it does.

      Both approaches have merit and should be used where it makes sense. When abstracting away some lower level detail, a separate method may be best, but when breaking a higher level method into it's higher level steps (if that makes sense), keeping it all in one method keeps it linear which can help with reading/review.

      It matters though how a method is broken up. Use whitespace to separate logical sections. Have a short comment at the top of each section to indicate what that section does. Write the comments first as an outline of the method. Declare variables where they are first used. Declare them in a limited scope where possible. Declare them const where possible (especially if method-global) to limit later misuse. In some languages you can introduce a nested scope for no other reason than to isolate local variables if you like.

      And note that breaking the method into separate sub-methods doesn't necessarily solve the problem of changes near the beginning breaking things later on. It just makes it harder to know where the "beginning" and the "later on" are.

    27. Re:Meh by optikos · · Score: 1

      Ada has them too.

    28. Re:Meh by ebno-10db · · Score: 1

      Lambdas and closures are really nice too - very powerful but easy to read and understand. I wouldn't say C++11 really makes nested functions simple enough to make them worth using much. You can do it with lambdas I suppose, but "misusing" them this way defeats much of the advantage of clarity that simple nested functions have. Now that you mention the similarity, it seems odd that they added lambdas and closures but not the related, and probably easier to implement, plain nested functions.

      Good points about some of the other languages, but unfortunately for me most of my "real" work is, and has to remain, in C/C++.

    29. Re:Meh by Anonymous Coward · · Score: 0

      For example, I've never had a manager look at my project and say "It has to be simpler!",

      He probably did have a manager (or some coworkers) who did say that, which is why he was motivated enough to write a rant on the topic.

      It's more likely that his best effort at coding "Hello, World!" resulted in 10,000 lines of source code and a dozen outside API's.

    30. Re:Meh by T.E.D. · · Score: 1

      And note that breaking the method into separate sub-methods doesn't necessarily solve the problem of changes near the beginning breaking things later on.

      That's a very good point. A lot of times these mongo routines really must be refactored to clean them up, and breaking them into sub-methods is really only the first step. If there's all sorts of exteranious interactions between blocks of code, and all you do is arbitrarially split the routine into multiple paremeterless routines operating on the same global data, you haven't really accomplished much. This is where the "coupling" I mentioned comes in. If you address the cohesion, but leave your routines with really crappy global coupling, I still have to read and understand the code in both routines fully to make sure routine A doesn't muck with globals in a way that subtly affects routine B.

      However, that's just a detail. It doesn't change the fact that any routine larger than about 300 text lines or so (1,000 is right out), with a few notable exceptions, has too much in it for a limited human such as myself to reliably keep track of, and needs to be broken up. Yes, there are some tasks that are inherently expressed as large routines (state-machines, command dispatchers) and thus can't be reasonablely split up. Its a rule-of-thumb, not religous dogma. That doesn't change the fact that large routines are hard to understand, and should be justified or refactored.

    31. Re:Meh by plover · · Score: 1

      Consider it from a testability standpoint. If a module is externally testable and provable, and it has a good name that defines what it does, it's a good place to draw the line. Writing testable code generally means making it readable and reusable.

      The other side of that is that a large, complex piece of code is hard to test. Having a complexity metric of 15 means that trying to go through all its paths could be impractical. If it's broken into smaller methods that each encapsulate a smaller idea of the complex whole, it becomes simpler and more readable - and more testable.

      I agree LoC is a crappy metric, but complexity gets closer to the heart of the problem. The higher the complexity, the less likely you are to have 100% test coverage - and that leaves room for bugs, misinterpretation, and a method that probably won't be reused.

      --
      John
    32. Re:Meh by XcepticZP · · Score: 1

      Python has inner functions. Ugly little bastards they are, but they are there none the less.

    33. Re:Meh by angel'o'sphere · · Score: 1

      No, he has no good point. And you just lost prestige.
      A function has a name. And the name expresses what the function does. If I see one writing a function/method wich is larger than one screen he gets brain washed, heavily. In fact I want them to write functions less than 15 lines. No need to call them multiple times, once is enough!

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    34. Re:Meh by XcepticZP · · Score: 1

      I'd argue that if you have to dig through lots of small functions, then someone is doing something wrong. Either you are in not looking in the appropriate place, or you're wanting to understand the entire codebase instead of the relevant parts. Or the initial writer of the code didn't name his methods/functions appropriately.

    35. Re:Meh by angel'o'sphere · · Score: 1

      You can use a trick in c++ to have local functions: make a local struct or class. (Yes you can define a class inside of a method or function) However such local functions have no access to local variables or parameters of the enclosing function, so you need to pass them in as parameters.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    36. Re:Meh by angel'o'sphere · · Score: 1

      No you are wrong. Or you mean something different. All those languages don't support nested functions.
      In fact the only languages I know are Pascal and Modula 2 that do that, and I believe Ada.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    37. Re:Meh by XcepticZP · · Score: 1

      You get programmers that do exactly that which you described, metaphorically. Rather than sitting down, reading the requirements, planning a design, and finding the over-arching concepts/requirements, they instead choose to take the path of least resistance first. They then proceed to piece-meal construct a solution after many many try-run-fail-alter tests. When the solution finally "works" they sit and refactor a little bit, after which they proclaim victory over that particular problem/requirement. A few days down the line, they repeat the same damn process when a relatively change is requested, as if they learnt nothing.

      The real question is, what do we do about them?

    38. Re:Meh by spiffmastercow · · Score: 1

      No, he has no good point. And you just lost prestige. A function has a name. And the name expresses what the function does. If I see one writing a function/method wich is larger than one screen he gets brain washed, heavily. In fact I want them to write functions less than 15 lines. No need to call them multiple times, once is enough!

      I admit it's more situational than I implied (careful reading of the word "may", for instance, goes a long way here). But it's important to note that there's very little few instances where code can't be refactored to less than a page without resorting to arbitrarily breaking it up into separate functions. If you absolutely can't break it down with code reuse or at least separation of concerns, there's a few options available. One of my personal favorites, discussed earlier in the thread, is nested functions (the advantage is that you're not crowding your namespace with one-offs, and it helps keep the code easy to find). Another is to separate your large function into regions.

      The point here is that, contrary to what you may think, it is *not* easier to read a bunch of tightly coupled functions that are arbitrarily split than it is to read one big function. It's like reading a heavily footnoted paper -- you spend all your time looking up the source and forget what you're doing.

    39. Re:Meh by spiffmastercow · · Score: 1

      simple C# example:
      public void Foo(int x) {
      Func<int,int> square = o => o * 0;
      Console.Write(square(x));
      }
      I use that as an example only because i'm a bit rusty on my python and scala.. But python and scala actually have much better support for nested functions, being able to do something along the lines of:
      def Foo(int x):
      def Square (int i): i * i
      Square(x)


      // Foo(5) result = 25

    40. Re:Meh by spiffmastercow · · Score: 1

      that c# example square lambda should read:
      Func square = o => o * o;

    41. Re:Meh by spiffmastercow · · Score: 1

      In my experience most attempts to reduce function line count without regard to code reuse leads to tightly coupled messes. It may not be apparent to the original developer, but the poor maintainer has to dig through tons of code randomly scattered about in order to make sense of what should be a linear function. Note that I also do not state this as dogma (carefully read my original post and you'll see that I say his coworker "may have a point", not that he necessarily does). There are times when you can create a nice distinction by splitting into multiple single-use functions, and this is best handled with nested functions if they're supporting in the language you're using. I would say this is the exception rather than the rule, however. Most code can be more cleanly broken up by reusable functions than non-reusable ones.

    42. Re:Meh by gmueckl · · Score: 1

      I consider lambdas and inner functions to be quite different types of biests. How would you write a lambda that has itself 10 to 20 lines of code? How would you nest another function inside a lambda expression?

      --
      http://www.moonlight3d.eu/
    43. Re:Meh by spiffmastercow · · Score: 1

      I consider lambdas and inner functions to be quite different types of biests. How would you write a lambda that has itself 10 to 20 lines of code? How would you nest another function inside a lambda expression?

      well, in C# you do this:

      public void Foo(int x) {
      Func pow = (num,pow) => {
      Func mult = (a, b) => a * b;
      int result = 1;
      for (int i = 0; i < pow; i++) result = mult(result, num);
      return result;
      }
      Console.Write(pow(x, 3));
      }

    44. Re:Meh by Anonymous Coward · · Score: 0

      Umm no retard, that implies I was and dropped it. Think my friend, you write like your 60 Holmes.

      No shit Shirlock.... Keep digging Watson!

    45. Re:Meh by ttucker · · Score: 1

      For what it's worth, and to hell with all of the naysayers that this post is guaranteed to attract, I hate monolith functions more than any other nasty programming habit. So, good for you.

    46. Re:Meh by Anonymous Coward · · Score: 0

      Do you re-use your functions, or do they only exist to break apart a single operation into smaller blocks? If it's the latter, then he may have a good point.

      So good that it evidently resonates with other bad programmers, to the point even of causing them to harass good programmers.

    47. Re:Meh by Luna+Argenteus · · Score: 1

      (lambda(x)
        (let ((fx (lambda(y) expr ...)))
          expr
        ;;put your 10 to 20 loc here
          ...))

    48. Re:Meh by spitzak · · Score: 1

      I agree, having just done some refactoring of a large chunk of code exactly like this.

      There were about 10 functions, spread between 4 source files in two directories and also duplicated in 4 header files. Some of the functions were entirely inline in the header files. Every single one of them was only called once, by one of the other functions. In a few cases one function called another with a lambda, when that called function could have just done the code in the lambda directly. Each of the functions took 8 or more parameters, pretty much the same set for each of them.

      It was a nightmare to straighten this out. I did not try to structure it, I just inlined the code from one function into another, being very careful to change the variable names in the many many cases where the called function used a different symbol for it's argument than the caller used to pass it. The result was about 300 lines of code.

      It is now possible to read one file and figure out how this code works, and to fix bugs without worrying that you don't know who else is relying on a function working the way it does.

      It is true that the final function is too large and should be split up. There is an if statement choosing between two courses of action in the middle which likely should be replaced with a virtual function on the base class and two subclasses. And a few other utility functions can be pulled out. But none of this has anything to do with the original structure and I consider the monolithic function a lot easier to figure out than the many small functions.

      A basic rule is that if it takes more than 2 arguments and is only called once, it should not be a function, just inline it.

    49. Re:Meh by Anonymous Coward · · Score: 0

      Using Aho's awk parsing code as an example of why "clean" code isn't always desirable is like using the US Marines as an example of why killing people is often a good option for solving disputes. Perhaps its true in a technical sense, but its really crappy advice to be giving the general public.

      Let's be semantically precise.

      Using awk as an example of why "clean" code isn't always desirable
      is like using the US Marines as an example of why killing people to solve disputes isn't always a bad idea
      it is not like using awk as an example of why "clean code" is not desirable
      it is not like using the US Marines as an example of why killing people to solve disputes is a good option

    50. Re:Meh by angel'o'sphere · · Score: 1

      Your example clearly shows, you don't know what a nested function is :)
      Your example is a closure, and as you named it and obviously want to reuse it, it MIMICS a nested function, but is not.
      Main difference: a nested function is static compiled. Your square is dynamic assigned at runtime.
      I'm not sure about Scala, but I believe it has no nested functions either, only closures.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    51. Re:Meh by spiffmastercow · · Score: 1

      Your example clearly shows, you don't know what a nested function is :) Your example is a closure, and as you named it and obviously want to reuse it, it MIMICS a nested function, but is not. Main difference: a nested function is static compiled. Your square is dynamic assigned at runtime. I'm not sure about Scala, but I believe it has no nested functions either, only closures.

      There's a lot that's wrong here, so I'll just go point by point.
      1.) This is not a closure, it's an anonymous function, which is analogous to a nested function. I purposefully coded it that way to avoid the confusion, though a closure is still a nested function, just of a specific variety. In C#, all closures are anonymous methods, but the reverse is not true. From the article:

      The term closure is often mistakenly used to mean anonymous function. This is probably because many programmers learn about both concepts at the same time, in the form of small helper functions that are anonymous closures. An anonymous function is a function without a name, while a closure is a function instance whose non-local variables have been bound either to values or to storage locations (depending on the language; see the lexical environment section below). An anonymous function may or may not be a closure, and a closure may or may not be anonymous.

      2.) Anonymous methods (including closures) in C# are compiled as separate static methods (closures are handled as a new type instead, but are still compiled). See here. You can structure something to be compiled at runtime, but that is a different issue.

      3.) The time at which a nested function is compiled has no bearing on whether or not it is a function. If that was the case, then you would have to claim that all nested functions in interpreted languages are not "true" nested functions. And since a nested function is just a function inside another function, you would then have to claim that interpreted languages do not support functions.


      So I suggest you do your research next time before you run your mouth.

    52. Re:Meh by spiffmastercow · · Score: 1

      Btw, this actually explains anonymous functions and lambdas much better.

    53. Re:Meh by angel'o'sphere · · Score: 1

      An anonymous function and a closure are the same thing, with two different words for it ...

      Ofc they are compiled "statically" but they are asigned dynamic to the variable you used in your example.

      My point simoly is: your examples are not nested functions but workarounds for the lack of native nested functions.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    54. Re:Meh by spiffmastercow · · Score: 1

      An anonymous function and a closure are the same thing, with two different words for it ...

      Ofc they are compiled "statically" but they are asigned dynamic to the variable you used in your example.

      My point simoly is: your examples are not nested functions but workarounds for the lack of native nested functions.

      No, they're clearly not the same thing, as you would see if you RTFA. Just because you say something over and over doesn't make it true.

    55. Re:Meh by angel'o'sphere · · Score: 1

      They always where the same thing ... I don't care what is written in a stupid article.

      Closure and anonymous functions ARE THE SAME THING. Even if you don't believe it ;D

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
  3. Einstein quote by olsmeister · · Score: 2

    The way I heard it was "Everything should be made as simple as possible, but no simpler." However I have since learned that me be a paraphrase of the actual quote, "It can scarcely be denied that the supreme goal of all theory is to make the irreducible basic elements as simple and as few as possible without having to surrender the adequate representation of a single datum of experience."

    1. Re:Einstein quote by phantomfive · · Score: 1

      Over on the c2 wiki there's a quote somewhere, "Judging things solely on the basis of simplicity is an overly simplistic approach." That seems to be what this guy is getting at, although his thinking isn't very clear.

      --
      "First they came for the slanderers and i said nothing."
    2. Re:Einstein quote by Tough+Love · · Score: 1

      Quote Invesigator (where you likely got your material from) makes a pretty good case that the modern quote actually originated from composer Roger Sessions in 1950, and may have been inspired by something Einstein had to say specifically about theories.

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    3. Re:Einstein quote by larry+bagina · · Score: 1

      Yeah, they simplified it.

      --
      Do you even lift?

      These aren't the 'roids you're looking for.

    4. Re:Einstein quote by Darinbob · · Score: 1

      It's just a simple restating of Occam's principle, so it's bound to have been said by many people over the centuries.

    5. Re:Einstein quote by Tough+Love · · Score: 1

      It's a rather nice formulation of it.

      --
      When all you have is a hammer, every problem starts to look like a thumb.
  4. Simple by Anonymous Coward · · Score: 0

    It is really very simple. If you write complex code to solve a problem, someone else solves with simple code, you have just shown your inferiority WRT the other engineer.

    "Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction."

  5. Yes! by Anonymous Coward · · Score: 0

    Hoorah!

  6. Sort of by Intrepid+imaginaut · · Score: 1

    In databases things get normalised down to their most basic elements, which is neccessary and good. In coding, everything might individually be simple, but the whole might be horrendously complex. Good documentation makes almost anything simple though, and by that I mean docs written intentionally to explain the overall codebase rather than disconnected sections.

    1. Re:Sort of by Anonymous Coward · · Score: 0

      Normalization only applies to a Relational Database.

      Even in a relational database, normalization is a set of rules that can be applied along a range of strict to loose depending on the circumstances of the usage. Saying normalization is always necessary and good is a misleading and inaccurate statement.

    2. Re:Sort of by Intrepid+imaginaut · · Score: 1

      Okay, most databases and most use cases.

    3. Re:Sort of by rjstanford · · Score: 1

      Have you ever looked at a 5NF database? They can be hugely inefficient and remarkably hard to get right.

      --
      You're special forces then? That's great! I just love your olympics!
  7. So the news is... by gentryx · · Score: 1

    Your code shouldn't be more complex than it really needs to be. But isn't that the way we thought about simple code all the time?

    --
    Computer simulation made easy -- LibGeoDecomp
    1. Re:So the news is... by roboticon · · Score: 1

      Your code shouldn't be more complex than it really needs to be.

      Obviously your writing is too simple, because he states the rule simply as "simplicity is the quality of code that is no more complex than required to express the underlying complexity".

    2. Re:So the news is... by Anonymous Coward · · Score: 0

      Yeah, I don't know who he is railing about with the editorial, but he says what I've been doing:

      This brings me to the point that is truly the heart of the matter: It's not simplicity that matters, but readability. Can the code be understood with the least amount of effort given its inherent complexity? That is the true criterion. How readable, or if you prefer, how maintainable is the code with respect to its complexity?

      The people who I think need to be berated are the folks who write the obfuscated code or do things like overload operators not because they need to, but because they can.

    3. Re:So the news is... by SirGeek · · Score: 2

      The people who I think need to be berated are the folks who write the obfuscated code or do things like overload operators not because they need to, but because they can.

      I think you mean beheaded. And their heads mounted on the wall above the server room :)

  8. Agree, but not completely by parallel_prankster · · Score: 5, Insightful

    I have often noticed that complexity is added to code when it grows over time. Typically, a project starts off very well. We have requirements and we use the best possible design with limited future expansion capabilities and come up with simple code that works well. However, over time, things change and we come across situations that the original code cannot handle. But instead of writing from scratch, we hack it and that is how complexity and subsequently bugs get added. In my experience, the base infrastructure code for any system always looks simplistic and beautiful. The ugly part is often how it has been used over the years.

    1. Re:Agree, but not completely by ADRA · · Score: 1

      Rewrites vs refactoring are all to common and this pattern is surely nothing new. One way is to design for change up front. This can be accomplished in many ways, but can be vastly simplified by cgood coupling/cohesion, as well as avoiding any kind of fixed constants. It may make initial implementation slower, but it'd leave the system in a better state for change in the future. Of course this flexability can itself lead to greater complexity, so buyer beware.

      Ultimately, we all code in different ways at vastly varying backgrounds and skill levels. If coding was just about me, it would do exactly what I want, and it would be quite simple, becase any code that I write (with appropriate comments) -should- be understandable by myself a year or two out. Introducing new people without perfect vision of how I code means there's always complexity. Thats why we establish common patterns. If nothing else they establish a language of coding which one would hope your co-workers understand enough to comprehend.

      Eg. In OO, if I have a class has words like Factory, Abstract, DAO/DTO, etc.. a developer should be able to infer the general use for these classes.

      --
      Bye!
    2. Re: Agree, but not completely by Anonymous Coward · · Score: 0

      Sometimes the code is more complex than it needs to be, even in the beginning of the project.

      Problems really start when this bad code is used and even copied many times. At that point most programmers think that it is impossible to fix and even best programmers need a week to fix it.

    3. Re:Agree, but not completely by parallel_prankster · · Score: 1

      Right, but then if you keep writing code for future expansion, you are over designing. A lot of the times, it is really hard to predict what direction this project is going to take. You also end up with pieces of code that are being maintained for future really. You do bring out another interesting point. Code that looks simple to me may not look simple to others.

    4. Re:Agree, but not completely by Tablizer · · Score: 1

      In finance there's the concept of Future Value in which the cost of the present is weighed more heavily than future costs. This also applies more or less to software: we know the here-and-now needs but the future is too murky in terms of product direction or even its very existence.

      One can learn a lot about design choices by studying finance theory because it trains you to better weigh probabilistic options and related costs in your mind. (Game theory has some similarities also.)

      I look for "bargain future-proofing" where if it's easy and only slightly more code to prepare for reasonable future changes, I'll go ahead add such to the initial design. However, if the candidate preparation adds significant complexity to the design without a high probability (roughly 70%) of actual need occurrence, then it's not worth it.

      It takes both programming experience and experience with the domain (industry type) to make good estimations of future directions.

    5. Re:Agree, but not completely by Anonymous Coward · · Score: 0

      It takes both programming experience and experience with the domain (industry type) to make good estimations of future directions.

      It's a lot simpler if you don't expect to be working in the same company for very long... ;)

    6. Re:Agree, but not completely by Anonymous Coward · · Score: 0

      The old maxim is: "There is never enough time to do it right the first time, but everyone believes that somehow there will be time to redo it later"

      I know plenty of people who justified poorly written code with the claim that we'll cut corner now to get it out and then later we can go back and redo it. It never happens. One never gets time to go back and redo it later, because there is always a deadline, emergency, fire to deal with.

      What happens by not taking the time to do it right the first time is that *every* subsequent development cycle gets longer and less predictable as all the short-cuts compound each other to make the platform less and less stable, and less and less predictable. And then everyone complains that products are shipping later than expected and they wonder why.

      This is also a fundamental flaw with the whole "agile" fad. It inherently assumes that one can "refactor" (meaning "rewrite") code later at a small cost. This is almost never the case because the original code, which wasn't well thought out, gets extended in odd ways (due to the lack of forethought) and then other pieces get built on top of it. Eventually, one realizes that to "refactor" the code means changing half the code you've written over the past N years. It becomes prohibitively expensive, and will *never* fit into a "sprint" and so people just continue to mangle the code in weird ways to get their next sprint to more-or-less work.

    7. Re:Agree, but not completely by darkgrayknight · · Score: 0

      I agree with your point. Most code I write has some amount of future proofing as there are usually signs that the client will want things added or changed in the future. I do limit these future capabilities to only those that can be implemented in a reasonable amount of time compared to ignoring them entirely. Anytime one codes with no thought on future changes, there will end up being a serious need to restructure or even just rewrite lots of code.

    8. Re:Agree, but not completely by sapgau · · Score: 1

      "reasonable future changes" is key based on the experience at hand.

    9. Re:Agree, but not completely by Tablizer · · Score: 1

      Cutting corners can risk damaging your reputation.

  9. Hello World! by Dareth · · Score: 1

    The is a good reason I need a separate class defined to output each character in the string "Hello World!"

    --

    I only look human.
    My mother is a halfling and my dad is an ogre, so that makes me an Ogreling
    1. Re:Hello World! by Cenan · · Score: 1

      Of course you do, how would you localize it if you didn't? Man, some people...

      --
      ... whatever ...
    2. Re:Hello World! by maxwell+demon · · Score: 1

      The is a good reason I need a separate class defined to output each character in the string "Hello World!"

      I see, you have to work on your abstraction. You certainly have to separate your character classes from your output classes. Don't forget to make proper base classes for both. For the abstraction, you know? Who cares that you'll only ever have one output class?

      --
      The Tao of math: The numbers you can count are not the real numbers.
    3. Re:Hello World! by fatphil · · Score: 2

      A separate class - are you mad? Just template them on , sheesh!

      --
      Also FatPhil on SoylentNews, id 863
    4. Re:Hello World! by Anonymous Coward · · Score: 0

      public class EntryPointClassForTheHelloWorldProgramMain
      {
      public static void main(java.lang.String[] commandLineArgumentsSuppliedByInvokingCaller)
      {
      try
      {
      CharacterResourceBuilderFactory characterResourceBuilderFactory =
      CharacterResourceBuilderFactories.newCharacterResourceBuilderFactory();

      CharacterResourceBuilder characterResourceBuilder =
      characterResourceBuilderFactory.newDefaultCharacterBuilder();

      CharacterResource h = characterResourceBuilder.getCharacterResourceForCharacter('h');
      CharacterResource e = characterResourceBuilder.getCharacterResourceForCharacter('e');
      CharacterResource l = characterResourceBuilder.getCharacterResourceForCharacter('e');
      CharacterResource l2 = characterResourceBuilder.getCharacterResourceForCharacter('e');
      CharacterResource o = characterResourceBuilder.getCharacterResourceForCharacter('e');
      CharacterResource space = characterResourceBuilder.getCharacterResourceForCharacter(' ');
      CharacterResource w = characterResourceBuilder.getCharacterResourceForCharacter('w');
      CharacterResource o2 = characterResourceBuilder.getCharacterResourceForCharacter('o');
      CharacterResource r = characterResourceBuilder.getCharacterResourceForCharacter('r');
      CharacterResource l3 = characterResourceBuilder.getCharacterResourceForCharacter('l');
      CharacterResource d = characterResourceBuilder.getCharacterResourceForCharacter('d');

      CharacterResourceCombinerFactory characterResourceCombinerFactory =
      CharacterResourceCombinerFactories.newDefaultCharacterResourceCombinaerFactory();
      CharacterResourceCombiner characterResourceCombiner =
      characterResourceCombinerFactory.newCharacterResourceCombiner();

      CombinedCharacterResources combinedCharacterResources =
      characterResourceCombiner.combine(h, e, l, l2, o, space, w, o2, r, l3, d);

      CombinedCharacterResourceOutputter characterReso

    5. Re:Hello World! by Anonymous Coward · · Score: 0

      Test "EntryPointClassForTheHelloWorldProgramMainOutputsStringHelloWorld" failed: Expected string: "hello world", Actual string: "heeee world"

    6. Re:Hello World! by Anonymous Coward · · Score: 0

      A separate class - are you mad? Just template them on <char>, sheesh!

      wchar_t, please! sheesh!

  10. Compare algebraic simplifications by Anonymous Coward · · Score: 1

    Why do we simplify expressions in algebra? Because ink is expensive? Because it takes too much time to write a lot of letters? Or because calculations are very hard to understand when they take up entire pages when they could be simplified to a few letters?

    1. Re:Compare algebraic simplifications by sapgau · · Score: 1

      +1

  11. good developers writes good code, bad ones don't by jellomizer · · Score: 1

    Writing code Simple or Complex really depends on the Developer and the mindset of the developer at the time.

    Sometimes the Simple Code actually makes it too hard to manage. Say you are given specs and you find it fits nicely in a mathematical function. So you create that function and it works fine, until a new change happens then you function is just wrong and you need to redo it. However if you make your code a bit more complicated, that change might be just a simple if statements, and you are all set again.

    The line depends on the skill of the developer. Having worked with recent grads who really did write good code, however lacked experience, got really frustrated at my designs because they accounted for "changes that wasn't in the specs". Why are you using a String instead of an Int, the int is faster and takes up less space, the data told us this element is a number. However my experience told me for that case you could come across a state where it could be a string. Months later there was an Oh By the Way We have this case which made it a string, and we didn't have to remap a bunch of fields. Experience is key.

       

    --
    If something is so important that you feel the need to post it on the internet... It probably isn't that important.
  12. Carpetbombing Philosophy by Anonymous Coward · · Score: 2, Insightful

    You know what's bad?
    An object with a single 2200 line method that takes 70 parameters

    You know what's also bad?
    300 tightly coupled classes that have no individual use.

    Striking the balance is what is really important and there's no one size fits all metric for that beyond peer review.

    I find myself cringing every time someone comes in and makes a grand sweeping statement about simplicity or density or whatever else because it ignores problems by carpet bombing a philosophy.

    Cyclomatic complexity doesn't mean much without analysis.

    1. Re:Carpetbombing Philosophy by SirGeek · · Score: 1

      You mean an MBA ?

  13. I like my data to be complex by Anonymous Coward · · Score: 1

    Not my code. As long as the data doesn't have to be turing-complete I'm satisfied.

    1. Re:I like my data to be complex by maxwell+demon · · Score: 1

      As long as the data doesn't have to be turing-complete I'm satisfied.

      I see, you wouldn't want to write a compiler. ;-)

      --
      The Tao of math: The numbers you can count are not the real numbers.
  14. Premise is wrong. by Anonymous Coward · · Score: 2, Insightful

    Any idiot can write complex code.

    Bzzt, wrong. It's:

    Any idiot can write complicated code.

  15. "rant" is a nice way of putting it by girlintraining · · Score: 5, Insightful

    "Simplicity is the ultimate sophistication."
    -- Leonardo da Vinci

    "Plurality should not be assumed without necessity."
    -- William of Ockham, often referred to as Ockham's Razor -- the simplest explanation is usually the right one.

    "Everything should be made as simple as possible, but not simpler."
    -- Attributed to Einstein

    "If you can't explain it to a six year old, you don't understand it yourself."
    -- Albert Einstein (attributed)

    "Truth is ever to be found in the simplicity, and not in the multiplicity and confusion of things." -- Issac Newton

    "Beauty of style and harmony and grace and good rhythm depend on simplicity."
    -- Plato

    "The greatest ideas are the simplest."
    -- William Golding, Lord of the Flies

    "Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage to move in the opposite direction."
    -- E.F. Schumacher

    "Those guys are all wrong."
    -- Andrew Binstock, Editor in Chief, Dr. Dobbs

    Choose well, reader...

    --
    #fuckbeta #iamslashdot #dicemustdie
    1. Re:"rant" is a nice way of putting it by chthon · · Score: 2

      In anything at all, perfection is finally attained not when there is no longer anything to add, but when there is no longer anything to take away.

      Antoine de Saint-Exupery (1900 - 1944)

    2. Re:"rant" is a nice way of putting it by fahrbot-bot · · Score: 1

      "If you can't explain it to a six year old, you don't understand it yourself."
      -- Albert Einstein (attributed)

      Having recently spent time with a friend and her six-year-old daughter, I can honestly, accurately, say that is not true. The kid is really, really smart - for a six-year-old - but, like *all* six-year-old humans, her brain simply isn't developed enough to grasp many - many - concepts. This also applies, to a lesser extent, to gifted kids (my wife was a Gifted Education teacher). In either case, any parents (or Albert Einsteins) who say otherwise are fooling themselves.

      --
      It must have been something you assimilated. . . .
    3. Re:"rant" is a nice way of putting it by Zalbik · · Score: 1

      "girlintraining didn't bother to RTFS, never mind RTFA"
      -- GoodCode

      Binstock addresses many of your "arguments" (if random proverbs by various authors, taken completely out of context can be called arguments) in the summary, never mind the article...

    4. Re:"rant" is a nice way of putting it by Anonymous Coward · · Score: 0

      "Knowledge is a single point, but the ignorant have multiplied it." [Hadith]

    5. Re:"rant" is a nice way of putting it by Anonymous Coward · · Score: 0

      Actually, the idea behind "Simplicity is the quality of code that is no more complex than required to express the underlying complexity" sounds an awful lot like "Plurality should not be assumed without necessity."

    6. Re:"rant" is a nice way of putting it by Anonymous Coward · · Score: 0

      -- Attributed to Einstein

      "If you can't explain it to a six year old, you don't understand it yourself."

      Attributed to Groucho Marx: "A child of five could understand this. Fetch me a child of five."

    7. Re:"rant" is a nice way of putting it by bananaquackmoo · · Score: 1

      To put it bluntly, you underestimate kids and overestimate yourself

    8. Re:"rant" is a nice way of putting it by Anonymous Coward · · Score: 1

      Hey there,

      > -- William of Ockham, often referred to as Ockham's Razor -- the simplest explanation is usually the right one.

      Mmm, not sure that's a good summary. "The simplest explanation is usually the right one" isn't what it's saying; it's more like "the simplest explanation is usually the best place to start".

      Ockham's Razor isn't really a guide to Truth. I think of it as a guide to making the Search for Truth efficient!

    9. Re:"rant" is a nice way of putting it by fahrbot-bot · · Score: 1

      To put it bluntly, you underestimate kids and overestimate yourself

      That's not it at all. I wasn't trying to be condescending (like you apparently are). Just stating a fact.

      No one, including your brightest six-year-old, is capable of understanding something before their brain is sufficiently developed. To argue otherwise indicates that *your* brain is insufficiently developed. I love my god daughter a LOT (and she loves me a LOT) and I think she's really - really - smart, but Quantum Mechanics is beyond her grasp at this point, no matter how well explained.

      Einstein was either over-simplifying or had never actually tried explaining something really complex to a six-year-old.

      --
      It must have been something you assimilated. . . .
    10. Re:"rant" is a nice way of putting it by Anonymous Coward · · Score: 0

      Well, Quantum Mechanics is probably not the best case for the Einstein quote: Einstein was staunchly opposed to Quantum Mechanics. Which is sort of funny considering that he actually received his Nobel Prize for his work on it. And since you can't get more than one Nobel Prize in physics, he never got any for his signature work on Special and General Relativity.

    11. Re:"rant" is a nice way of putting it by sapgau · · Score: 1

      Fine then, replace "six" with "twelve" so you can explain simply all your nerdy theories.

    12. Re:"rant" is a nice way of putting it by Anonymous Coward · · Score: 0

      FYI: g.i.t. gets an automatic mod bonus for being "brave."

      (Hint: dude looks like a lady now)

    13. Re:"rant" is a nice way of putting it by angel'o'sphere · · Score: 1

      Perhaps you simply have not understood what you wanted to explain to the 6 years old :)

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    14. Re:"rant" is a nice way of putting it by angel'o'sphere · · Score: 1

      The brain of a six year old is "sufficient developed".
      Kids get born with "sufficient developed" brains.

      You mix up "knowledge" with "inteligence". A kid does not know as much as you do. So you have to explain complicated stuff in the frame of their knowledge. That is difficult for YOU, as you have to restrict yourself.

      Most dumb people are dumb because their parents or their environment makes them dumb.

      Most young kids are in fact geniouses ... but somehow they get stopped in their development pretty early.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    15. Re:"rant" is a nice way of putting it by Anonymous Coward · · Score: 0

      I have to disagree.
      It may take a lot longer to explain it to a six year old, simply because they don't have the underlying knowledge needed to understand your explanation.
      So you would need to explain that first. If you can't do that you don't really understand it.
      Name something that a six year old could not grasp if you explained it properly. (in this case I'm talking about technical things, and not explaining why candy is bad for them.)

    16. Re:"rant" is a nice way of putting it by DerekLyons · · Score: 1

      Whenever someone trots out that tired old tripe... I'm reminded of the evolution of submarine ballast and trim systems. The earliest were supremely simple (read obvious), but had deadly (and non obvious) failure modes... (Long story short, they were unstable longitudinally and could easily pitch the boat onto it's beam ends.) John Holland's great breakthrough was to make the system more complex - and his concepts from the late 1800's can be found replicated almost exactly (though more complex in detail) in submarines being built today.
       
      And you see the same thing replicated in engineering again and again, the trend is towards more complexity (and higher performance) - not towards simplification.
       
      The moral of the story? Don't take engineering advice from non engineers.

    17. Re:"rant" is a nice way of putting it by Anonymous Coward · · Score: 0

      "When a young man, I read somewhere the following: God the Almighty said, 'All that is too complex is unnecessary, and it is simple that is needed' ... So this has been my lifetime motto – I have been creating weapons to defend the borders of my fatherland, to be simple and reliable."

      - Mikhail Kalashnikov

    18. Re:"rant" is a nice way of putting it by Anonymous Coward · · Score: 0

      It is possible that you are fooling yourself into rejecting the wisdom of Einstein because of your failure to explain concepts to the six-year-old, of course.

      She can't grasp concepts in the same way you grasp them, perhaps. But if you understood them fully (and had the time) you could explain them in a way she could grasp. There is your failure, and there is Einstein's point, which went whoosh for you, because you're apparently not willing to entertain the possibility that you are not the best person in the world at explaining things to six-year-olds. It's not about how smart she is, it's about how smart you are. Hint: if you disagree with Einstein, 99 times out of 100 it's because of your own hubris.

  16. interesting topic, disappointing article by dirtyhippie · · Score: 2

    Frankly, I was a little disappointed in this article. His arguments seems a bit - for lack of a better term: simple.

    Is there anyone out there who is arguing that simple solutions to inherently complex problems exist and are a good thing?

    1. Re:interesting topic, disappointing article by Anonymous Coward · · Score: 0

      printf("yes");

      That one simple statement actually does a LOT of stuff. The % operators are hellish to get just right (unless you do not mind memory over/under runs). Many implementations get something as simple as

      short xyz = 1;
      printf("%d", xyz);

      Results in a memory overrun in many versions of printf.

      right way is
      printf("%h", xyz);

      That is but one example of something complex that is simple to write that is hard to get right.

    2. Re:interesting topic, disappointing article by Hentes · · Score: 3, Insightful

      Complex problems are defined as problems with no simple solution. The article is not just simple, it's a tautology.

    3. Re:interesting topic, disappointing article by fahrbot-bot · · Score: 2

      Frankly, I was a little disappointed in this article. His arguments seems a bit - for lack of a better term: simple.

      Well... Any idiot can make a complex argument. :-)

      --
      It must have been something you assimilated. . . .
    4. Re:interesting topic, disappointing article by Anonymous Coward · · Score: 0

      That one simple statement actually does a LOT of stuff. The % operators are hellish to get just right (unless you do not mind memory over/under runs)

      The simple solution: use a more modern language. Don't waste your time using the wrong tool for the job. (If your printfs are in a performance-critical section, just put down the keyboard and find a new career)

    5. Re:interesting topic, disappointing article by Anonymous Coward · · Score: 0

      what platform are you using where a short isn't promoted to an int when passed as an argument?

    6. Re:interesting topic, disappointing article by hawguy · · Score: 1

      printf("yes");

      That one simple statement actually does a LOT of stuff.

      Not really, it just passes a pointer to a string as vararg to a function named "printf". There's not much complexity in that statement. The printf function may be complex, but that's why it's in a standard library -- so programmers don't need to reinvent the wheel every time they need to do some common task.

      The % operators are hellish to get just right (unless you do not mind memory over/under runs). Many implementations get something as simple as

      short xyz = 1;
      printf("%d", xyz);

      Results in a memory overrun in many versions of printf.

      right way is
      printf("%h", xyz);

      That is but one example of something complex that is simple to write that is hard to get right.

      Aren't short's in a vararg supposed to be automatically promoted to int's by the compiler (and floats to doubles)? If this is true, then sounds like this case isn't "hard to get right", it's just plain wrong and will likely cause problems with every function that accepts varargs.

    7. Re:interesting topic, disappointing article by Anonymous Coward · · Score: 0

      it's just plain wrong and will likely cause problems with every function that accepts varargs
      Yes it is everywhere. Let me flip that around a little and demonstrate.

      long long xyz = 256*256*256*256*256;
      printf("%d", xyz);

      What does that print? Depends on the version of printf you are using. I have seen it break in at least 3 different crts out there both closed and open source. Then act differently depending on which version of compiler you are using.

      It gets even more squirly when you use scanf. I spent many days fixing many many a printf/scanf. Both valgrind and boundschecker found the errors. Match your types or you will suffer. There are some types that do not map to printf on one platform and will on another.

      My point was not to have an argument about a bug (a common easy one too). But to show how easy it is to get something so simple wrong. The designers of printf/scanf assumed people read the docs completely and understand every % type that goes into it.

      I picked the printf example deliberately because it is usually taught early on in many C classes. Even some of the people who responded to me gave me snark such as 'use a more modern language'. Yeah, like I have that choice all the time in my projects.

      Also even you made the same mistake I did "Aren't short's in a vararg supposed to be automatically promoted to int's by the compiler" . The answer is yes it should. The real world is maybe or maybe not. Depends on the compiler. When targeting 10 different compilers you do not play 'it should'. You check. I found ARM/MIPS compilers tend to get it right. x86 compilers tend to vary as the platform is more forgiving with memory alignment issues.

    8. Re:interesting topic, disappointing article by paavo512 · · Score: 1

      It is well known for a long time already that each complex problem has a simple, elegant, wrong solution.

    9. Re:interesting topic, disappointing article by angel'o'sphere · · Score: 1

      You are perfectly right.
      And on top of that formatting a short as an int can't end in a "memory overrun" anyway as a short is less or equal to an int in size.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    10. Re:interesting topic, disappointing article by hawguy · · Score: 1

      it's just plain wrong and will likely cause problems with every function that accepts varargs
      Yes it is everywhere. Let me flip that around a little and demonstrate.

      long long xyz = 256*256*256*256*256;
      printf("%d", xyz);

      What does that print? Depends on the version of printf you are using. I have seen it break in at least 3 different crts out there both closed and open source. Then act differently depending on which version of compiler you are using.

      Since the behavior when printing a long long with the %d conversion specifier is undefined, I'm not sure how it can be said to break when there's no definition for what should happen... it could print the "right" value, an incorrect value, core dump, or the computer could lift itself off the desk and smack the developer on the head, and any of those would be valid behavior since there's no definition of what "should" happen. The %d format specifier is documented to work with int's, not long longs, you want %lld for a long long. That's a little like passing a URL to fopen() and saying that it failed because it didn't open a stream to the URL. Mavbe you're working on a platform where stdio works differently and you can print a long long with %d, but don't expect that to work everywhere.

      It gets even more squirly when you use scanf. I spent many days fixing many many a printf/scanf. Both valgrind and boundschecker found the errors. Match your types or you will suffer. There are some types that do not map to printf on one platform and will on another.

      My point was not to have an argument about a bug (a common easy one too). But to show how easy it is to get something so simple wrong. The designers of printf/scanf assumed people read the docs completely and understand every % type that goes into it.

      If a programmer doesn't understand the API for a particular function, he really shouldn't be using it, and he shouldn't be surprised that undefined behavior is inconsistent across compilers and architectures, since that's pretty much what "undefined" means. You may say that the comments to 'use a more modern language' were snarky, but one advantage of some of those languages is that they can help the programmer from accidentally running into this type of mistake. C has its place and sometimes it's the only real choice, but it's going to do less to help the developer play within the rules than some other languages.

      I picked the printf example deliberately because it is usually taught early on in many C classes. Even some of the people who responded to me gave me snark such as 'use a more modern language'. Yeah, like I have that choice all the time in my projects.

      Also even you made the same mistake I did "Aren't short's in a vararg supposed to be automatically promoted to int's by the compiler" . The answer is yes it should. The real world is maybe or maybe not. Depends on the compiler. When targeting 10 different compilers you do not play 'it should'. You check. I found ARM/MIPS compilers tend to get it right. x86 compilers tend to vary as the platform is more forgiving with memory alignment issues.

      Any C compiler that doesn't promote shorts to ints doesn't comply with the C standard, so it's not really a C compiler (of course, on some platforms, an int may be the same a short, so you should always be explicit if you're writing cross platform code). So yeah, if you're using a compiler that is almost, but not quite, a C compiler, you'll run into a variety of problems, and it adds to code complexity because you can't count on the undocumented non-standard behavior remaining there across newer (or older) versions of the compiler so you'll have to allow for different behavior across different compilers.

  17. PEP20 by RobbieCrash · · Score: 3, Interesting

    Beautiful is better than ugly.
    Explicit is better than implicit.
    Simple is better than complex.
    Complex is better than complicated.

    Flat is better than nested.
    Sparse is better than dense.
    Readability counts.
    Special cases aren't special enough to break the rules.
    Although practicality beats purity.
    Errors should never pass silently.
    Unless explicitly silenced.
    In the face of ambiguity, refuse the temptation to guess.
    There should be one-- and preferably only one --obvious way to do it.
    Although that way may not be obvious at first unless you're Dutch.
    Now is better than never.
    Although never is often better than *right* now.
    If the implementation is hard to explain, it's a bad idea.
    If the implementation is easy to explain, it may be a good idea.

    --
    Keep on knockin'
    https://robbiecrash.me
    1. Re:PEP20 by darkstar949 · · Score: 1

      If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea.

      Those two always bother me though because when it comes to software development it always seems like there is an exception to every rule. Something like Ukkonen's algorithm is both hard to explain and a good idea and that's just the first one to come to mind.

    2. Re:PEP20 by RobbieCrash · · Score: 1

      The concept seems more difficult than the implementation in that case, which I don't think is the point of those lines.

      I always looked at those lines as don't do result = d.x(y + l.u(v[i[m + 4*t.base(vvv)]])) when you can instead spread it out over a few more lines and make it more readable, less Perly. Either way, you're still going to need the logic figured out, but one is easy to explain and figure out at a glance, while the other is a bunch of back and forth and what the fucks.

      --
      Keep on knockin'
      https://robbiecrash.me
    3. Re:PEP20 by maxwell+demon · · Score: 1

      But sometimes spreading an operation over several lines makes it harder to read. For example, given the lines

      ar = br*cr - bi*ci;
      ai = br*ci + bi*cr;

      I can spot immediately that this is a complex multiplication. Spread the same code over several lines each, doing only one operation per line, and It will take me some time to figure out.

      --
      The Tao of math: The numbers you can count are not the real numbers.
    4. Re:PEP20 by bidule · · Score: 1

      Simple is better than complex.
      Complex is better than complicated.

      This.

      Even good programmers sometimes add unnecessary complications. How often can a direct mess be rewritten as the difference of 2 simple calculations. When distributing width across panes after a resize, modulo distribution is much harder than calculating both states.

      --
      ID: the nose did not occur naturally, how would we wear glasses otherwise? (apologies to Voltaire)
    5. Re:PEP20 by sapgau · · Score: 1

      I don't get your example, I think you omitted the complex part.
      Doing that is normal, looking at your example I will then be expecting that you will do further work with 'ar' and 'ai'.

    6. Re:PEP20 by maxwell+demon · · Score: 1

      I don't get your example, I think you omitted the complex part.

      No, I didn't. ar is the real part of a, ai is the imaginary part. Same for br, bi and cr, ci.

      --
      The Tao of math: The numbers you can count are not the real numbers.
    7. Re:PEP20 by Anonymous Coward · · Score: 0

      Beautiful is better than ugly.
      Explicit is better than implicit.
      Simple is better than complex.
      Complex is better than complicated.

      Flat is better than nested.
      Sparse is better than dense.
      Readability counts.
      Special cases aren't special enough to break the rules.
      Although practicality beats purity.
      Errors should never pass silently.
      Unless explicitly silenced.
      In the face of ambiguity, refuse the temptation to guess.
      There should be one-- and preferably only one --obvious way to do it.
      Although that way may not be obvious at first unless you're Dutch.
      Now is better than never.
      Although never is often better than *right* now.
      If the implementation is hard to explain, it's a bad idea.
      If the implementation is easy to explain, it may be a good idea.

      That's why I use Perl.

    8. Re:PEP20 by angel'o'sphere · · Score: 1

      You still can implement the hard to explain algorithm in even harder to explain code, or in code that is adequate.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    9. Re:PEP20 by Anonymous Coward · · Score: 0

      I think sapgau isn't understanding that you're multiplying complex numbers. He thinks you're doing a multiplication which happens to be complex to do.

    10. Re:PEP20 by Anonymous Coward · · Score: 0

      Frankly, I'd go for more straightforward n log n -solution. Heck, chances are that it's actually faster too.

  18. No good examples in article so I can't agree by locopuyo · · Score: 1

    I didn't see any good examples in his article. The only example he had was a switch statement with 35 cases being simplified by using a table which somehow makes it harder to read than scrolling through a 35 case switch statement. I'm not convinced at all. This guy sounds like he could benefit from reading Clean Code by Robert C. Martin.

    1. Re:No good examples in article so I can't agree by darkstar949 · · Score: 1

      This guy sounds like he could benefit from reading Clean Code by Robert C. Martin.

      I wouldn't be supprised if "Clean Code" is what prompted the article in the first place.

    2. Re:No good examples in article so I can't agree by Anonymous Coward · · Score: 0

      Yup. Martin's "Clean Code" is all about making individual functions as small as possible, at the expense of exploding the overall codebase into an over-abstracted mess.

    3. Re:No good examples in article so I can't agree by Anonymous Coward · · Score: 0

      Or the clean myPC guy.

  19. Good design is simpler than no design by joeaguy · · Score: 2

    Simplicity is word that gets batted around a lot. When it used to mean "the shortest distance to a solution to the immediate problem", you are often trading immediate simplicity for longer term inflexibility.

    I've found the simplest solutions are those which are well designed, which take into account not just the immediate problem at hand, but reasonable future variations of that problem. The up front investment in thought and design and pay off in a big way down the road when new problems can be solved more elegantly, quickly, and be more maintainable.

    Its like someone who collects books. You could just stack them up on the floor, but finding one or adding more is going to increase the chance that they all fall over. If you take the time to get some bookshelves and think of a cataloging system, your book collecting is going to scale much better.

    Good design and good structure benefit simplicity. If you ignore it, you are just pushing complexity into the future.

  20. Sometimes too much of the complexity is hidden by jandrese · · Score: 1

    I see this a lot with the various "on rails" development schemes, where they sweep a tremendous amount of complexity under the rug so users can quickly develop whatever they want. Only later they discover that something is broken or slow with their project and now fixing it requires a herculean effort because they never really understood what was happening before. It's discouraging and many projects just resign themselves to being broken or start to incorporate ugly workarounds to try to avoid the problem without really fixing it.

    --

    I read the internet for the articles.
    1. Re:Sometimes too much of the complexity is hidden by iggymanz · · Score: 1

      plenty of successful rails projects around, doing important work.

      maybe the teams you speak of have another problem, between their ears.

  21. My code is always simple by jbeaupre · · Score: 1

    I limit it to 1's and 0's

    --
    The world is made by those who show up for the job.
  22. Obviously he needs to apply the rule... by gentryx · · Score: 1

    ...to his writing, too. Or, as Antoine de Saint-Exupéry has put it: "A designer knows he has achieved perfection not when there is nothing left to add, but when there is nothing left to take away."

    --
    Computer simulation made easy -- LibGeoDecomp
    1. Re:Obviously he needs to apply the rule... by Anonymous Coward · · Score: 0

      in other words, Build first, Optimize later

  23. Clever code by Teckla · · Score: 2

    Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?

    -Brian Kernighan

    1. Re:Clever code by gweihir · · Score: 1

      "As clever as possible" means "as complicated as possible" here, not as "elegant, simple and clear as possible".

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    2. Re:Clever code by fatphil · · Score: 1

      Knuth? (Or at least just 2 days ago I saw it attributed to Knuth, but didn't check it.)

      --
      Also FatPhil on SoylentNews, id 863
    3. Re:Clever code by swilver · · Score: 1

      Now, BK is a big name, but I disagree with him anyway.

      Code that is trying to be clever probably had a lot of debugging time already gone into it during development, for example in the form of the programmer testing inputs with some throwaway test program -- but this is not counted as "debugging it". If you do however, then you realize that debugging that clever piece of code took much more time than writing it.

      Now if instead the code was designed with easy debugging in mind (not tightly coupled, easily used in isolation, acts just only on its own inputs), then that code would take longer to write and structure, and maybe even become a bit more complex because you cannot take short-cuts that would reduce testability. Yet this code would be easy to debug. Discover a new edge-case? Find out its inputs, test the code in isolation, and fix it without breaking your other tests.

    4. Re:Clever code by Rockoon · · Score: 1

      ..yet elegant is not always simple, at least to the standard observer.

      --
      "His name was James Damore."
    5. Re:Clever code by Anonymous Coward · · Score: 0

      Twice as hard can mean you'll just have to spend twice as long to fix it, not necessarily be twice as clever.

  24. He just redifined everything. Its a strawman. by Karmashock · · Score: 4, Interesting

    When you redefine your opposition's argument and then knock it down with your own argument it is called a strawman. That's what he just did there.

    No one is saying in regards to simplicity that all programs should be two line bits of nothing.

    What people are instead saying is that code should be efficient, tight, and achieve the end goal as simply and directly as possible.

    What we are and have always been talking about is efficiency. It goes back to the first computers that had very limited memory. They required VERY efficient code because they simply didn't have the storage or memory to run anything that took up more space. As a result, code for those machines tended to be very very efficient. It was a requirement.

    When we complain about complexity, we are not complaining that the task of the program is too complex. Rather, we're complaining that the program is badly coded. We are complaining that it is inefficient and disorganized.

    So nice try. Try again.

    --
    I've decided to stop wasting my time responding to AC trolls/sockpuppets... so if you want a response from me... login.
    1. Re:He just redifined everything. Its a strawman. by Anonymous Coward · · Score: 0

      Actually - today it's considered good programming to prefer some simplicity over some efficiency. That is - shaving a few lines of code in exchange for extra complexity is not considered a good merit.
      Shaving an unnecessary loop, however - is usually deemed worth the extra complexity that it might bring.

      Of course it's more complicated than that - if a code sits in the critical path of a real time application - than it might be extremely complex - to shave those 5 extra function calls.

      The zen of python defines the complexity issue quite clearly:

        Simple is better than complex.
              Complex is better than complicated.

    2. Re:He just redifined everything. Its a strawman. by ak3ldama · · Score: 1

      If I recall correctly - I read the article a day or two ago - he was also arguing for simplicity via readability and understandability. He basically said nothing in the whole article. Complex code can be complex: via some awk example. Whoever that guy is... (I am of course being sarcastic.) but that code that can be simple and easier understood should be.

      A particular avenue I have seen this discussion played out is when you encounter heavily "patterned" code. It is "simple" in that specific context but what happens when no one else understands the pattern yet and has to spend time to learn it? I think for some situations this is ok but for others the "cost" is too great.

      --
      "but money is the God of Algiers & Mahomet their prophet." - Rich. O'Bryen June 8th 1786
    3. Re:He just redifined everything. Its a strawman. by roman_mir · · Score: 1

      One realises these kinds of things when one has to go over code that uses various equivalents of 'goto' statement that are present in every type of computer language and so it is abused. One cringes when seeing things like 60 page long methods / functions, where logic is controlled with a number of local state variables and control switches are implemented as exceptions that are thrown from random places in code, multiple nested try/catch scopes are used to check for the types of exceptions, combinations of exceptions are used to represent transition from one logic state to another and all of this also relies on various database and asynchronous method calls to pull in data for decision making about when exceptions are thrown.

      When this sort of thing is analysed and re-implemented with simple control flows, calls to meaningfully named methods, simple if, switch conditions and loops, all of a sudden 60 page code can be condensed down to maybe 15 pages. That's when one learns to appreciate the beauty of real simplicity, not simplicity for the sake of simplicity, but simplicity in the sense of structural approach to solving a problem.

    4. Re:He just redifined everything. Its a strawman. by Karmashock · · Score: 1

      Sounds like another man that's seen the horror of spaghetti code.

      That's really the issue here. No one has a problem with complexity if what you're doing is complicated. Its just a question of not making it MORE complicated then it needs to be or making it incomprehensible.

      --
      I've decided to stop wasting my time responding to AC trolls/sockpuppets... so if you want a response from me... login.
    5. Re:He just redifined everything. Its a strawman. by Anonymous Coward · · Score: 0

      No, I think you misunderstand his argument. Some people create metrics to determine a program's "complexity", then judge programs on an absolute scale based on that metric.

      This argument is saying that those metrics are bullshit because they don't take into account the difficulty of the problem at hand.

      dom

    6. Re:He just redifined everything. Its a strawman. by gl4ss · · Score: 1

      but it might seem disorganized despite being effective. it might take a while to find out which functions you need to mess with or which functions from a complex api will help you.

      and some simple things are extremely inefficient and there's nothing more frustrating than an API that os vendor has put on top of some lower level functionality and made it too simple because the jackasses couldn't hold a meeting to decide how to display the complex inner workings that are inherently complex because the device it's supposed to expose is complex - so the api has just doThingA(); when it should have a b c and doApartiallyAndSpitOutTheMidwayResult. ending up with situations of "yeah, that would be cool but you see this particular platform is a pile of shit so we can't do that". yeah, there's lots of devices/platforms where such situations occur. that's of course entirely different form having an api that is just hard to use because they implemented just 20% of what they specced up and in a fashion that you can only call it one particular way in a particular order for it to work(yay symbian! let's let the subcontractors implement our developer facing api's so they'll do intentionally bad job and start companies purely by being the only persons who know how they work!) - that however is not being complex, it's just being shit.

      --
      world was created 5 seconds before this post as it is.
    7. Re:He just redifined everything. Its a strawman. by Karmashock · · Score: 1

      Again, strawman.

      I didn't say make something so simplistic it doesn't work.

      I said make it as simple and efficient as possible. And yes, simplicity is almost always more efficient. It is POSSIBLE for something to be more simple yet less efficient but it is highly unlikely.

      And regardless, I'm really just talking about the distinction between sloppy and tidy code.

      Sloppy code is what I'm arguing against here. Sloppy, trashy, poorly documented, redundant code.

      When people argue against complexity THAT is really what they're talking about. If it needs to be complicated then it needs to be complicated. There is no argument there. However, if it doesn't NEED to be complicated then it shouldn't be complicated. Make it as simple as possible. It will run better, be easier to maintain, and won't make other programmers roll their eyes.

      --
      I've decided to stop wasting my time responding to AC trolls/sockpuppets... so if you want a response from me... login.
    8. Re:He just redifined everything. Its a strawman. by konohitowa · · Score: 1

      Defining efficiency would be a first step. Self-scavenging and self-modifying code fits into limited resources, but it's still complex. I once asked billg why the MS BASIC interpreter didn't tokenize numeric constants. He claimed that they pulled out the code for that to fit into 4k ROMs. So integers and reals that were encountered by the interpreter had to be parsed at each and every occurrence. The workaround was to create variables for all constants (I'd call them named constants but they were rarely longer than 2 letters). This is an example of being efficient with ROM usage and inefficient with storage (numbers represented in ASCII rather than machine) and inefficient with CPU (the constant reparsing).

    9. Re:He just redifined everything. Its a strawman. by Karmashock · · Score: 1

      Again, we're not talking about something just being small. We're talking about it being TIGHT.

      If the program is more efficient if its a bit longer then most would agree that is superior.

      We are also talking about how neat the code is and how well documented it is and how much spaghetti is in it.

      Can we all agree that spaghetti code is bad? Because in large part what I think we want is for code to be written and then rewritten when its all over the place. Think of it like writing a term paper.

      You write out a rough draft. The draft is very similar to the end paper. But it probably isn't as nicely structured and you might need to flesh out a couple things. The final draft is often a complete rewrite of the rough draft using the rough draft as an outline.

      We need more of that in coding. Coding and proof reading the the whole program. Will it run if its badly organized and inefficient? Probably. But its a mess and its probably a good deal slower then it would be otherwise.

      Sloppy code is bad code. That is what we're saying here.

      --
      I've decided to stop wasting my time responding to AC trolls/sockpuppets... so if you want a response from me... login.
    10. Re:He just redifined everything. Its a strawman. by Anonymous Coward · · Score: 0

      Once upon a time when there was a situation where there might be a thing to process or there might not, I'd have used a special hardcoded placeholder value and conditionally jump over the routine. Today, I might foreach a list instead. It doesn't matter that it doesn't (yet?) have more than just 1 item. Simple or complex?

  25. My Complex Rule by Anonymous Coward · · Score: 0

    If you write some code and you can't explain what it does, without reading comments or external documentation, then it was written in a way should be simplified.

    1. Re:My Complex Rule by gweihir · · Score: 1

      That will fail once you do more complicated things. The benchmark is whether the code with its documentation can be understood in a reasonable amount of time with respect to the complexity of the problem solved. You should make code as simple as possible, but not simpler. You are trying to make it simpler than possible.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    2. Re:My Complex Rule by Anonymous Coward · · Score: 0

      That will fail once you do more complicated things. The benchmark is whether the code with its documentation can be understood in a reasonable amount of time with respect to the complexity of the problem solved. You should make code as simple as possible, but not simpler. You are trying to make it simpler than possible.

      I disagree. If your comments or documentation are out of date or incorrect then you just made it twice as hard to understand.

  26. coding becoming like fine wine by Anonymous Coward · · Score: 0

    Complex, simple, OOA/D, functional, good coders, bad coders, sloppy code, hacked code, elegant code, modular code.

    Coding is truly an art much like producing fine wine.
    And like fine wine, no one gives a damn. It's freaking alcohol... not grape juice...

    In conclusion, code just needs to damn work for the given purpose and be maintainable for the target skill level to maintain it. That's it, who cares about complex vs simple. Much like fine wine, as long as it's alcohol no one really cares on the making part.

    1. Re:coding becoming like fine wine by sapgau · · Score: 1

      God you sound like my manager and I cringe everytime

  27. Lame excuse by Teckla · · Score: 1

    I'm afraid software developers will read this article and use it as a lame excuse to write complex code, because it's easier to write complex code than to write simple code, though it's much, much harder to maintain, enhance, and debug complex code.

    Complex code hides bugs. Complex code is generally less robust and reliable. Complex code usually has more security holes.

    Sure, some things have to be complex. But generally, you should strive for small functions (methods) that do one thing, and do it well, and keep side effects as localized as possible.

    And the same applies up the stack. Make sure each layer (methods -> objects -> programs -> etc.) alone can be grokked inside the head of a single person. This is how you manage complexity. This is how you build big systems.

    1. Re:Lame excuse by gweihir · · Score: 1

      Indeed. And it applies to architecture and design just as well:

      "There are two ways of constructing a software design: One way is to make it
      so simple that there are obviously no deficiencies, and the other way is to
      make it so complicated that there are no obvious deficiencies. The first
      method is far more difficult." --Tony Hoare

      Writing complex code where simple code would be adequate and much clearer is the hallmark
      of incompetence.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
  28. Once again reinventing Fred Brooks by dkleinsc · · Score: 3, Insightful

    Brooks made a big point in "No Silver Bullet" about the difference between what he called accidental complexity (introduced by the developers) and essential complexity (introduced by the reality of the problem). And the key thing is that the accidental complexity needs to be avoided or fixed with tools, but the essential complexity can't be avoided.

    --
    I am officially gone from /. Long live http://www.soylentnews.com/
    1. Re:Once again reinventing Fred Brooks by gweihir · · Score: 1

      Exactly. And where you face essential complexity, make sure what you do is as clear and well-structured as possible. "Simple" does not mean "simplistic".

      Funny thing is no real engineers have any problems with that idea or are unaware of it. It is just people in IT that seems to still struggle with fundamental engineering concepts.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    2. Re:Once again reinventing Fred Brooks by Anonymous Coward · · Score: 0

      Funny thing is no real engineers have any problems with that idea or are unaware of it. It is just people in IT that seems to still struggle with fundamental engineering concepts.

      Hey, I work in IT and I would take offense at that statement if the bit about people in IT weren't so true.

      It's not everybody, though. But yeah, overall it's a mess.

      Fortunately, there's a lot of effort put into fixing the parts that are not broken so things should look different in a few years. ;)

    3. Re:Once again reinventing Fred Brooks by g2devi · · Score: 1

      That's not totally correct. If there is too much essential complexity, it is generally possible to find a simple approximate solution that is good enough. You just need to go back to the client to verify it's acceptable given the alternative.

      Case in point, NP complete problems cannot be simplified, but it's nearly always possible to find a polynomial timee solution that's at is "good enough" for many cases.

      Another case in point, the president of Walmart wanted to know the percentage of customers who entered the stores and bought items. The IT team came up with a sophisticated solution that involved RFIDs and face recognition at entrances to determine this tally. The president shook his head and instead asked the non-techie Walmart managers for a solution. They suggested "Greeters" who would do this tally and help people as a side benefit. While this solution is less accurate than the IT solution, it's good enough for planning.

    4. Re:Once again reinventing Fred Brooks by gweihir · · Score: 1

      I agree that it is not everybody and I did not mean to imply that. Sorry, if that was unclear. It is just far, far too many people in IT with this problem. I have my doubts about this being fixed anytime soon though. It seems to get worse from what I can see

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
  29. Obsession with simplicity all about offshoring by Anonymous Coward · · Score: 0

    Use bright, talented programmers to get the initial job done, throw "simple" code across the ocean to $3/hr code monkeys in India.

    1. Re:Obsession with simplicity all about offshoring by gweihir · · Score: 1

      "Code monkeys" in India are not able to do simple things in a simple way. They have a tendency to introduce unneeded complexity, because of deficient education and lack of experience. I have seen this several times, at least once with project-killing consequences.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
    2. Re:Obsession with simplicity all about offshoring by Anonymous Coward · · Score: 0

      Nail on the head -- I still cringe looking back at some of the most hellacious complicated crap I had the pleasure of "fixing". The overall design the original coders (contractors in India) took was absolutely wrong -- simple problems solved in the most complicated way you can imagine (think Rube Goldberg machines). In the end I threw it all out and rewrote the thing over a months time (it took them over six months to produce the original implementation).

      The new implementation supported far more cases (ie: more robust, supported more environments), took approximately half as many LOCs, and was drastically easier to comprehend (more maintanable), used less memory, and ran a lot faster.

      Simple and maintanable code is _hard_ to write -- it is a skill developers continue to hone over their entire careers. Some "code monkey" straight out of high-school / college really has no clue.

    3. Re:Obsession with simplicity all about offshoring by Anonymous Coward · · Score: 0

      at least once with project-killing consequences.

      If a fuse blows in a house in LA and the entire Western Seaboard goes black, that's not a result of faulting house wiring ... ;)

  30. Gone are the days by ChrisMaple · · Score: 1

    Dr. Dobb's Journal's motto was once "Running light without overbyte." Looks like this valuable maxim is now beyond their ability.

    Sometimes it's a good choice to use more complex code when it provides a substantial speed increase. Sometimes it's good to slap something together just so it will run. But if there's no substantial advantage to code that isn't simple, simple is best.

    --
    Contribute to civilization: ari.aynrand.org/donate
  31. Man bites dog by Tough+Love · · Score: 1

    Black is White. Freedom is slavery. Simplicity is bad. Complexity is good. Binstock is +1 Funny.

    --
    When all you have is a hammer, every problem starts to look like a thumb.
  32. what? by serbanp · · Score: 1

    The article is mildly entertaining (especially for the awk bits), but the ending is plain stupid, i.e. flat and inane beyond belief ;-)

    I don't think that a sane person would explain the apparent improvement of newish cars reliability by the increasing number of built-in programmable gadgets with their millions of code lines. If anything, there is an optimum beyond which the cars will start failing in new and spectacular ways...

  33. The truth revealed by sl4shd0rk · · Score: 2

    "I had incorporated some sophisticated regular expression pattern-matching.."

    So many simple projects turn the corner of complexity, and never look back, right about at that statement.

    --
    Join the Slashcott! Feb 10 thru Feb 17!
    1. Re:The truth revealed by Anonymous Coward · · Score: 0

      ``Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.`` -jwz

    2. Re:The truth revealed by PuZZleDucK · · Score: 1

      "I had incorporated some sophisticated regular expression pattern-matching.."

      So many simple projects turn the corner of complexity, and never look back, right about at that statement.

      Yeah, he could have just used an ad hoc, implementation of Common Lisp to do the regular expression pattern-matching;p

      --
      Can a person program a new solution to a problem? Why should anyone be able to stop such a thing? -Richard Stallman
  34. Workarounds make code complex by jmyers · · Score: 1

    A lot of what makes code ugly and complex is working around bugs and incomplete features in languages, database, etc. Every time I start a new project I try to start with a good clean framework. If never fails that you hit a point where documented features dont work and after waisting many hours of research you find the ugly hack workarounds. These acheive the end result but make you cringe when you maintain the code.

    1. Re:Workarounds make code complex by Anonymous Coward · · Score: 0

      waisting? acheive? Reading your comment makes me cringe. Too lazy to use a spell-checker?

  35. It's about the human, not the computer by Tablizer · · Score: 1

    "Readability and change-ability by future maintainers" should be the primary goal. Obtaining that goal doesn't necessarily lead to the most simplest (smallest) code.

    However, it's often a difficult goal to codify (describe precisely) because human psychology and physiology are still half-science-half-art subjects. And, every individual is different and thinks and sees better under different circumstances compared to other individuals.

    It's best to get multiple opinions on different styles to try to find a consensus.

    This reminds me of a debate on the readability of a sample Lisp case-like and IF-like statement set versus the VB equivalent of a given application. To me the VB version just looked easier to read than the Lisp version despite Lisp being smaller in the test, partly because VB forces certain line-spacing and repetitious keyword conventions on you. It looked closer to how one may document an algorithm on paper for quickest visual absorption. You lose some compactness because of that, but a consistent and familiar "product" can improve visual identification of the parts.

    The Lisp fan claimed that "one will eventually get used to" the Lisp approach and it would grow easier to read for anybody who tried long enough, not just him. I'm a bit skeptical of that claim, plus my future replacement may not have that experience and be starting from scratch reading Lisp.

    The Algol-style block constructs (as found in VB, C, ADA, etc.) are deeply ingrained in most developers. Even if it was possible to "get used to" Lisp's approach, the pool of experienced Lisp developers may have to reach a certain size threshold in order to make replacement staffing viable for a typical company.

    The Algol style has been time-tested, and very few tech companies have gotten rich from Lisp despite being popular with graduates. The pudding doesn't favor Lisp yet.

    (C's case/switch statement really needs an overhaul, BTW, at least for derivative languages of C where machine speed is a secondary concern.)

  36. Clarity is what is actually important by gweihir · · Score: 1

    KISS is not "make it simple". KISS is "keep it as simple as possible while retaining clarity, but not simpler". It is about not adding complexity _unless_ needed. Anybody competent understands that. This "rant" is entirely redundant and shows a lack of understanding of fundamental engineering principles.

    --
    Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
  37. Bill Atkinson -2000 lines of code by WillAdams · · Score: 1

    The problem is there isn't a way to determine from a simplistic line of code metric whether or no a line is truly needed, resulting in sloppy bloated code.

    Every line of code which is properly designed out of a block of code is a line which will not have to be executed, debugged, stored or every worried about again:

    http://folklore.org/StoryView.py?story=Negative_2000_Lines_Of_Code.txt

    --
    Sphinx of black quartz, judge my vow.
    1. Re:Bill Atkinson -2000 lines of code by sapgau · · Score: 1

      +1 Cool story

  38. Re:good developers writes good code, bad ones don' by Anonymous Coward · · Score: 0

    You're the guy who puts all those dictionaries in the code with strings as keys. I hate you.

    captcha: damage

  39. Debugging "simple code" sometimes terrible by hsmith · · Score: 1

    I've had to debug systems where code was abstracted so much - to make such simple routines that it was nearly impossible to debug. So, though simplification helps - sometimes writing a long routine maybe preferable.

    1. Re:Debugging "simple code" sometimes terrible by sapgau · · Score: 1

      So true, this is the reason why java error stack dumps are so huge

  40. unemotional? by phantomfive · · Score: 1

    My view of simplicity is unemotional and free of idolatry

    Calling your opponents 'idolaters' is the opposite of unemotional. It is an emotionally charged indication that you don't actually understand the other viewpoint.

    --
    "First they came for the slanderers and i said nothing."
  41. How Long Is A Man's Arm? by guttentag · · Score: 2

    In journalism school I had a professor who had personally interviewed the Dalai Lama and as a result he often had a very practical outlook on things. When he gave us our first writing assignment (an obituary for a famous person of our choice who was still alive... I decided William Safire had died of a heart attack upon learning that genetic testing proved Hillary Clinton was not, in fact, a congenital liar), someone immediately asked how many column inches he wanted. He replied with a question: "How long is a man's arm?" People started trying to measure their arms against things or guesstimate the average length of a man's arm, asking if that meant he wanted 30 column inches. Finally he quieted everyone and said, "A man's arm is long enough to get the job done. No more. No less." Likewise, the articles we were to write were to be long enough to get the job done. No important things left out, no filler added in. It was an important lesson in judgment.

    I think the same applies to code. It should be just complex enough to get the job done. No more, no less. Sometimes that means you're going to have complex code, but it shouldn't be any more complex than it needs to be.

  42. His only source contradicts him by Hentes · · Score: 2

    "I had incorporated some sophisticated regular expression pattern-matching technology into AWK Brian Kernighan once took a look at the pattern-matching module that I had written and his only addition was putting a comment, 'Abandon all hope, ye who enter here.' As a consequence, neither Kernighan nor Weinberger would touch that part of the code. I was the one who always had to make the bug fixes to that module"

    Even the source he cites admits that complex code is a bitch to maintain.

    1. Re:His only source contradicts him by gl4ss · · Score: 1

      "I had incorporated some sophisticated regular expression pattern-matching technology into AWK Brian Kernighan once took a look at the pattern-matching module that I had written and his only addition was putting a comment, 'Abandon all hope, ye who enter here.' As a consequence, neither Kernighan nor Weinberger would touch that part of the code. I was the one who always had to make the bug fixes to that module"

      Even the source he cites admits that complex code is a bitch to maintain.

      yeah so? even the summary states that it's probably harder to maintain - doesn't mean it's necessary. +it's reg exps related so it being maintainable easy is out the window anyways. if it was piece of code that was trivial to replace with something else it would probably have happened in the project, but being as it is the replacement might have been totally unmaintainable(in this case it was maintainable given effort).

      --
      world was created 5 seconds before this post as it is.
    2. Re:His only source contradicts him by Anonymous Coward · · Score: 0

      Ooh. Hire me! Hire me! I am a perl programmer and all my code is one line long.

  43. When dealing with egos by Anonymous Coward · · Score: 0

    You claim to be a brilliant programmer, yet don't give me an elegant solution to an interesting problem. That's truly the set of problems -- ego, elegance, and interest. Most of us are writing software that's boring, aren't truly in the small brilliant fraction, and the problesm we are addressing are uninteresting.

  44. That article is void of content. by Anonymous Coward · · Score: 0

    The only "example" he brings is one of awk where the matching module by Aho was labelled as unmaintainable by other programmers. Then basically Binstock states "Aho is a superb programmer, so the module must have been written as simple as possible". What rubbish. It's like stating that a great pianist will find the best fingerings for a piece he plays well, and you just need to write them down.

    The actual truth is that a great pianists will find fingerings intuitively that suit their skill set and style of playing. But that does not mean that most of them are fit for writing down, publishing and teaching to others.

    Good fingerings are matched to the problem space, not to the performer space. And good code matches the problem space to the tool space, the used language and libraries.

    The article does not get any of this. It just harps about "complex problems exist, so complex code is fine". The truth is that the concepts underlying complex code can usually be expressed in an understandable manner: read "The Art of Computer Programming" for a lot of examples. And transferring the structure and transparency of a good human-readable description to code without large losses is an art requiring lots of diligence and a thorough grasp of the language and its patterns, and how they match the problem patterns.

    Hacking code from the ground up is pretty much the opposite. And particularly hard-core programmers who can read core dumps, back traces, assembly and so on dive into the mind frame of the machine rather than the abstract representation of the problem in human-understandable terms. They need discipline to pattern their code along the lines of the principles of the solution.

    And I should know. I learnt coding when the output was made available hours after your input (and that includes compilation errors), possibly with a core dump. I soldered my first computer together myself. When I bought my first disk drive, I had to write bootstrap loader and BIOS (in assembly language, of course) before being able to boot first time.

  45. His main point by phantomfive · · Score: 1
    The summary misses (what I consider) his main point, but here it is:

    This brings me to the point that is truly the heart of the matter: It's not simplicity that matters, but readability. Can the code be understood with the least amount of effort given its inherent complexity? That is the true criterion. How readable, or if you prefer, how maintainable is the code with respect to its complexity?

    --
    "First they came for the slanderers and i said nothing."
  46. I disagree by stanlyb · · Score: 1

    The problem is not that the complex code is "bad", but that there are many stupid developers using pretty much complex libraries and modules, and don't forget the copy/paste methodology, and the result is something that is "somehow" working, and extremely complex and hard to read. Well written and maintained code is always pleasure to read, no matter its complexity or the used libraries. One more thing, give an idiot a hammer, and every problem he face would look to him like a nail.

  47. Isn't his example arguing against him? by hawguy · · Score: 1

    This quote from TFA seems to argue *against* complexity:

    "I had incorporated some sophisticated regular expression pattern-matching technology into AWK Brian Kernighan once took a look at the pattern-matching module that I had written and his only addition was putting a comment, 'Abandon all hope, ye who enter here.' As a consequence, neither Kernighan nor Weinberger would touch that part of the code. I was the one who always had to make the bug fixes to that module" (from Masterminds of Programming, p. 103). Complex problems require complex code.

    So he wrote some code that was so complicated that no one besides himself is able maintain it. That sounds like more of an argument *against* complicated code than for it.

    Note that it's not Al Aho that said "Complex problems require complex code". Is awk still using the same code today, or has it been rewritten to be more maintainable?

    1. Re:Isn't his example arguing against him? by Anonymous Coward · · Score: 0

      I think most implementations by now have been bootstrapped off lex/yacc or their equivalents and/or regexp libraries. The result is not that the C code is any simpler, but that the human-written input is processed mechanically by human-written tools, and that the concepts accessible to humans are expressed much more directly, leaving the translation of those concepts to code mostly to the computer under control of well-separated tools.

      This does not reduce the complexity of the binaries, but it means that each area of complexity is confined in its own, separate code base.

  48. Buzzword Warnings by Anonymous Coward · · Score: 0

    Be wary of people who fill code with too many buzzword concepts in fake preparation for a fake future. It's often just job security in disguise.

    Most "patterns" meant to add flexibility often introduce other change hindrances: it's rarely a free lunch and they are merely gambling on a certain pattern of change. If you hard-wire change handlers for the wrong kind of change, ones that go against the "grain of the wood" of the actual future, it's worse than having a simpler design to begin with.

  49. Re:good developers writes good code, bad ones don' by Anonymous Coward · · Score: 0

    Whatever, input and output may very well be strings as they can be from different character sets for example. Internally a number is a number. Formatting should be done with the input or output only(even within the program itself), in your case handled by the individual state for that case only. You fail. You don't change your entire paradigm because of "someday" scenarios.

  50. he'd still be wrong, see machine code by raymorris · · Score: 4, Insightful

    Compare .NET code to the compiled machine code.
    Which is easier to understand and work on? The .net runtime is nothing but a set of functions in a separate file. using simple functions means main()can be an outline of the program, for example .

    By any measure, Linus Torvalds is an incredibly successful programmer. His guideline is 6-8 lines per function or so.

    Consider these two example programs:
    Stand
    Turn left
    Walk four steps
    Turn right
    Walk two steps
    Turn right ... 1000 more lines

    Vs:
    heatlunch()
    readslashdot()

    Even if the function heatlunch() is used nowhere else, using it makes the program far more understandable than inlining the walking code to get to the microwave.

    1. Re:he'd still be wrong, see machine code by spiffmastercow · · Score: 2, Insightful

      Compare .NET code to the compiled machine code. Which is easier to understand and work on? The .net runtime is nothing but a set of functions in a separate file. using simple functions means main()can be an outline of the program, for example . By any measure, Linus Torvalds is an incredibly successful programmer. His guideline is 6-8 lines per function or so. Consider these two example programs: Stand Turn left Walk four steps Turn right Walk two steps Turn right ... 1000 more lines Vs: heatlunch() readslashdot() Even if the function heatlunch() is used nowhere else, using it makes the program far more understandable than inlining the walking code to get to the microwave.

      But you forget you also have to walk back to your desk.. At that point, you have two usages of a pathing algorithm.. Which means you're repeating code, which means that using a function to enable code re-use instead makes sense. I'm hardly an advocate for complex functions (most of my code are 1 or 2 liners), but there are times when you simply cannot express something concisely in a short function, and the answer to that is *not* to artificially reduce it into code that does nothing but resides in a different location.

    2. Re:he'd still be wrong, see machine code by DahGhostfacedFiddlah · · Score: 5, Insightful

      On the other hand, even if code isn't used in more than one place, that doesn't mean it's not "expressing something concisely".

      Additionally:
      1) Methods are great ways of naming orthogonal snippets of code, rather than using a comment that may become obsolete.
      2) Breaking large methods into smaller ones increases maintainability by enforcing certain constraints such as not reusing variables declared 100 lines up just because they happen to serve similar purposes.

      I agree that you don't want to just arbitrarily break your method up for the sake of smaller methods, but I don't think reuse is necessarily the best way to judge whether methods should be refactored.

    3. Re:he'd still be wrong, see machine code by Anonymous Coward · · Score: 0

      I believe his point was not that it reduces the code, but that it improves the maintainability by allowing the reader to quickly black-box functionality that is not of immediate interest.

      When fixing a bug causing an internet browser to crash, the newly assigned programmer does not need to know how you microwave your food or how to find a path; they would be able to see, just by reading the function name, that they will probably want to dig deeper into the readSlashdot function.

    4. Re:he'd still be wrong, see machine code by plover · · Score: 1

      But you forget you also have to walk back to your desk.. At that point, you have two usages of a pathing algorithm.. Which means you're repeating code, which means that using a function to enable code re-use instead makes sense. I'm hardly an advocate for complex functions (most of my code are 1 or 2 liners), but there are times when you simply cannot express something concisely in a short function, and the answer to that is *not* to artificially reduce it into code that does nothing but resides in a different location.

      I think you missed his point that "heatLunch()" was far more readable than "stand/turn left/walk 4 steps...". If you were defining lunch activities, you might have a lunchtime() event that has two methods: eatLunch() and readSlashdot(). eatLunch() might be made up walkToKitchen(), prepareLunch(), eatLunch(), and goBack(). walkToKitchen() could be start=getLocation(); path=navigateFromTo(start, kitchen); walk(path). prepareLunch() could be made of of cookLunch() and serveLunch(), and so on. Each task is progressively built up from simpler subtasks.

      At any point you can look at the small contents of a routine and understand what it's doing at that context, but you don't necessarily need to know the larger context you're a part of. Reading the contents of walkToKitchen() doesn't imply I have to know anything about the lunchtime() event, certainly no more than seeing me walking proves that it's lunchtime. But all together, each of those small, simple steps add up to lunchtime.

      --
      John
    5. Re:he'd still be wrong, see machine code by spiffmastercow · · Score: 1

      On the other hand, even if code isn't used in more than one place, that doesn't mean it's not "expressing something concisely".

      Additionally: 1) Methods are great ways of naming orthogonal snippets of code, rather than using a comment that may become obsolete. 2) Breaking large methods into smaller ones increases maintainability by enforcing certain constraints such as not reusing variables declared 100 lines up just because they happen to serve similar purposes.

      I agree that you don't want to just arbitrarily break your method up for the sake of smaller methods, but I don't think reuse is necessarily the best way to judge whether methods should be refactored.

      You make a fair point there. I'm fully satisfied with breaking code into "reusable" blocks, even if they aren't "reused". My complaint is more toward tightly coupled functions, which is what I often see in refactoring scenarios.

    6. Re:he'd still be wrong, see machine code by ttucker · · Score: 1

      You cede one good point while ignoring an even better one, namespace pollution in a huge function is almost as horrible as using a bunch of global variables.

    7. Re:he'd still be wrong, see machine code by DahGhostfacedFiddlah · · Score: 1

      Yeah - I've seen that too, but I rarely write them (anymore :)). For instance, I'll sometimes see a bunch of small methods that all access the same global variables, or rely on state changes to parameters passed between them. That's worse than the monolithic method they originally came from.

      The trick is to ensure that each method neatly encapsulates a single concept, and the concept is a "What" rather than a "How".

      isExpired(Date): Great
      isTwoYearsInThePast(Date): Bad

      The longer I've been coding, the more convinced I've become that the most undervalued strength a coder can have is picking the perfect name for a variable or method.

  51. Einstein said it best by Anonymous Coward · · Score: 0

    Make everything as simple as possible, but not simpler.

    I take that to mean that you don't want an undue complexity in your model, but your solution will be as equally complex as the problem you are trying to solve. If you take software system that is complex enough to warrant OOP style classes, interfaces, etc. and you instead decide to write "simple" code and do it all in one big-assed function, you have in fact made the solution more complex, or you are missing key elements that should be supported.

  52. Simplicity by Anonymous Coward · · Score: 0

    Simplicity is always natural and it never shows any extra humour and emotion.
      http://www.Kaffesmagen.dk

  53. Over-complexity is more common issue though by SuperKendall · · Score: 1

    I totally agree with the assertion that some things are inherently complex.

    But it's not bad to place "simplicity" out there as a goal anyway, because programmers in general tend to create overly complex solutions, so anything that makes them think a little and reign in that tendency is a good thing.

    Thinking along those lines can help act as a check to premature optimizations which often add complexity that is not needed.

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
  54. If you want to talk to a computer... by tekrat · · Score: 1

    If you want to talk to a "digital computer", ultimately, your code has to be translated into on/off (1, 0) pulses. Therefore, the simpler, the better. Unless the author of this article has another type of computer that can understand more complex states than on/off, his entire treatise is bunk.

    I know there used to be analog computers, and quantum computing might have states other than on/off, I can't speak for these systems. However, the more common digital computer is what I am referencing.

    --
    If telephones are outlawed, then only outlaws will have telephones.
    1. Re:If you want to talk to a computer... by Anonymous Coward · · Score: 0

      If you want to talk to a "digital computer", ultimately, your code has to be translated into on/off (1, 0) pulses. Therefore, the simpler, the better. Unless the author of this article has another type of computer that can understand more complex states than on/off, his entire treatise is bunk.

      Modern and even not-so-modern computers do not read bits like they did from punchcards, where this approach would be as you say. Instead they take in bytes of memory at a time and interpret these groups of bits as different instructions. Compilers are a level of abstraction again and are what most programmers now use to write programs.

      Just because people are ultimately a collection of quarks and electrons, doesn't mean that anyone thinks of people as such -- apart from an ocasional physicist. These physicists make statements that make sense to them, but you should be wary when management starts to simplify and spout similar things.

  55. Simple or complex, it's all about documentation by Anonymous Coward · · Score: 0

    I have seen a few very simple lines of code that are an absolute nightmare to maintain, all because there was very little commenting or documentation as to what the code was responsible for doing. Whether the code is butt-simple or extremely complex, the key to understanding it is the documentation.

  56. tame complexity with useful abstractions by dickens · · Score: 2

    Even very complex problems can be made to look simple at various levels of abstraction. Hiding complexity inside objects that represent real-world objects is a good way to make the code that uses those objects simpler.

    In development, plan to do at least one major refactoring after the project is feature-complete to move complicatons in and out of abstractions, add new abstractions or collapse old old ones as needed to make things "feel good".

  57. Write complex code if you want to by petes_PoV · · Score: 1
    ... but then YOU get to maintain it ... forever.

    If nobody else can understand the stuff you wrote, then you have created a problem and it's up to you to solve it. If you are prepared to do that, then fine. Be a slave to your code for the rest of your career.

    However, if you want to write code and move on then you can act professionally and create product that others can take off you and use as your legacy. it can still be complex - just so long as you can explain in the documentation why it is complex and what the (complex) functions actually do. You never know: those who follow might even learn something valuable from your output - rather than learning not to go anywhere near your stuff in the future.

    --
    politicians are like babies' nappies: they should both be changed regularly and for the same reasons
  58. What's the most complex part of code? by fustakrakich · · Score: 1

    Probably the licensing...

    --
    “He’s not deformed, he’s just drunk!”
  59. Think about the other developers by Anonymous Coward · · Score: 0

    Sometimes you can't avoid complexity but if unavoidable abstract the complex stuff and put it behind a bunch of facades or something. If it works, then nobody has to go back there, i.e. developers how aren't as skilled or don't like complexity. ;)

  60. Garbage Can Coding by DahGhostfacedFiddlah · · Score: 2

    I liken this to an overflowing garbage can. Every subsequent coder delicately places his code on top of the steaming pile, praying that it all holds together.

    Then someone makes one too many changes. The pile topples, and the poor sod who touched it last is the one who has to take the garbage out (rewrite it).

  61. Monday Morning Airchair Quarterback by amiak · · Score: 0

    Captain Obvious to the rescue

    --
    accurately define good according to a criteria and seek it out.
  62. UNIX mantra by ezdiy · · Score: 1

    But ... but ... what about "first 10% of coding effort give 90% of the functionality"? (Or 20/80% split, as per Pareto principle in general).

    I've been living in a lie :/

    These arguments all sound kinda silly, much like underscore_naming(), preferred in unix, vs StudlyCase as seen in win32 world and various corporate programming shops (java..).

  63. The code that runs an airliners avionics... by gatkinso · · Score: 1

    ...is probably complex as hell.

    But I bet there is very little spaghetti in that massive and complex code base.

    --
    I am very small, utmostly microscopic.
  64. Reduce, Reuse, and Recycle by Anonymous Coward · · Score: 0

    I have spent nearly a decade refactoring 5 of the worst codebases out there. This guy is full of shit. Go back to whitepapers, dummy. Make it seem more than it is so the customers are impressed over nothing.

  65. Elegant vs Simple/Complex by Rastl · · Score: 1

    Is the code elegant? Does it fulfill its requirements while maintaining flexibility and maintenance abilities? Does it take advantage of existing objects?

    I don't care if it's 10 lines or 1,000 as long as it's elegant. Clever programming is not elegant - it's generally a hack because someone wants to show how much more they know than everyone else. Spaghetti string code is not elegant - it's lazy.

    That's part of writing good code. Make it elegant. Make it something that when the next person opens it up you can't hear the frustrated groan from across the room.

    That's my opinion and how I try to write my code.

  66. Is This News and Does it Really Matter? by Anonymous Coward · · Score: 0

    Maybe I'm out of the loop, but I didn't realize there was an obsession with simple code. I've been saying for years that code should be as simple as possible and as complex as necessary. I didn't realize this wasn't already common sense and that I could get an article published about it. Honestly, if your code is simpler than it should be it probably isn't getting the job done. And who wants code that is more complex than it needs to be? OK, I've definitely had some co-workers who seem to go out of their way to make their code as complex as possible, but I've been hoping that they are the exceptions.

  67. Speaking of complexity by sapgau · · Score: 1

    I was just reading this article and I stopped at this paragraph, unable to understand it:

    "Standing Accretion Shock Instability," or SASI. This term expresses the fact that the initial sphericity of the supernova shock wave is spontaneously broken, because the shock develops large-amplitude, pulsating asymmetries by the oscillatory growth of initially small, random seed perturbations."

    http://www.sciencedaily.com/releases/2013/06/130627083034.htm

    No clue if that could be expressed in a more simpler form.

  68. They Misunderstand The Problem by Anonymous Coward · · Score: 0

    Of course you have no choice but to deal with no less than the complexity that is required by the needs of the business problems you're trying to solve.

    What I and many others object to is the ridiculous over-complexity that is added to an application just to serve the Ego of the Lead Designer. For example, I worked for a company where this dickwad lead went crazy essentially built his own application-server environment. In so doing, he massaged his ego but made life miserable for anyone who had to work on and maintain this piece of tripe. The first day I started working for the company he crowed about how he had made all these hard choices to have sub-500ms response times. After that initial conversation, I and everyone else who worked there understood what a joke that goal was. The over-complex design meant that the app barely met 10x that benchmark. I never heard another mention of the sub-500ms response times. It was and is a total joke. So, the application was a pile of spaghetti, with none of the usual tools you have at your disposal. The same guy had a dozen annoying OCD habits that just made him a nightmare to deal with. The application itself was full of whack a mole bugs and only happy-path coding that made it take weeks to solve a bug that should have taken a day or two.

    The complexity that I and many others object to is UNNECESSARY, EGO-STROKING complexity, such as using Hibernate when there are only 6 tables in the database, or using iBATIS for the tiniest app.

    In the Java space, one of the only bits of complexity that earns its keep is the Spring stack--but if you hadn't noticed, the dominance of the Spring Framework stems from its insistence on reducing complexity, getting rid of checked exceptions and needless boilerplate.

    Another kind of needless complexity is pulling in a brand-new technology and all its problems, version conflicts and breakages when you're only using 5% of its capabilities, such as pulling in MongoDB when you really don't need it and are not using it for any big datasets.

    EgoChumps like Mr Chips are a nightmare to work with. A nightmare.

  69. insightful...? Re: Its a strawman. by Fubari · · Score: 1
    AC here is closer to the mark than the gp's strawman assertion.
    This is the heart of Binstock's reasoning from TFA, with some of the more insightful parts bolded to make it easier to follow along.
    If you didn't like TFA, please help me understand where he gets it wrong...

    begin excerpt:

    There's a big difference between poorly written code and complexity.
    Unfortunately, parts of the Agile movement have tended to obfuscate the distinction.
    A rule of thumb I've seen cited several times is that functions with a cyclomatic complexity number (CCN) of more than 30 or 35 must be rewritten.
    This is patent nonsense and implies that all complex code is equivalent to badly written code.
    Moreover, there's a peripheral problem with the assertion; namely, that every branch of a switch statement adds 1 to the CCN.
    So, if your switch has 35 branches, you violate the threshold with no reasonable way to simplify your code.
    (Sure, you could use some kind of table instead of the switch, but now you've taken logic that was easy to read and made it considerably more difficult to follow.)

    Parent post:

    No, I think you misunderstand his argument. Some people create metrics to determine a program's "complexity", then judge programs on an absolute scale based on that metric.

    This argument is saying that those metrics are bullshit because they don't take into account the difficulty of the problem at hand.

    dom

  70. elusive simplicity by epine · · Score: 1

    Something like Ukkonen's algorithm is both hard to explain and a good idea and that's just the first one to come to mind.

    Suffix trees and suffix arrays make for a brilliant study of elusive simplicity.

    Suffix array

    A well-known recursive algorithm for integer alphabets is the DC3 / skew algorithm of KÃrkkÃinen & Sanders (2003).

    The paper includes a 50 line reference implementation (excluding comments).

    One of the first algorithms to achieve all goals is the SA-IS algorithm of Nong, Zhang & Chan (2009). The algorithm is also rather simple (< 100 LOC) and can be enhanced to simultaneously construct the LCP array. The SA-IS algorithm is one of the fastest known suffix array construction algorithms. A careful implementation by Yuta Mori outperforms most other linear or super-linear construction approaches.

    Why wasn't this algorithm discovered thirty years ago?

    The concept was first introduced as a position tree by Weiner (1973), which Donald Knuth subsequently characterized as "Algorithm of the Year 1973". The construction was greatly simplified by McCreight (1976) , and also by Ukkonen (1995).

    It's not like people didn't recognize this algorithm is an important building block since way back. Thirty six years to arrive at "rather simple". Amazing.

    Yeah, and one more thing: Slashdot has been around for sixteen years and still can't render diacritics pasted in from Wikipedia. Who could have anticipated we'd wish to use those? Besides, it's a good American tradition. Right after being awestruck by the Statue of Liberty, Karkkainen steps off the boat and declares his name to the port authority.

    Karkkainen? What kind of name is that? Umlaut schmoomlaut. You can have Kirkby or Kirklen. Kirlen it is then. What's that? I missed a K? Whatever, no point starting over. Next!

  71. Re:good developers writes good code, bad ones don' by sapgau · · Score: 1

    So the meta data indicated to convert strings to ints otherwise they meant to be used as a code or something.
    Sounds like you got lucky, those assumptions could come back to bite you. It's best to confirm with the domain expert, never assume!

  72. Code vs writing by phorm · · Score: 1

    One thing about code though, is that's it's often more re-usable than an essay or an article.

    In some cases, you might favour writing a function/module/etc that's slightly more complex but able to service more scenarios. That allows the code to be more useful in the future, either in anticipation of growth in the current project or for use in future projects.

  73. Missing the point by jgotts · · Score: 1

    I didn't read the article, so your mileage may vary, but I have been programming since I was around 7 or 8 years old and I just turned 38.

    Here goes. The vast majority of code that you will need to write and maintain does simple things. It should be simple and expressive so the next person can both fix your mistakes and add new behavior.

    Every once in a long while you will be given something fairly complex to do, and as you gain experience you learn to isolate that complex piece, perhaps write tests and drivers, special debugging code for it, documentation and wiki entries, and otherwise treat that code specially so it doesn't become a burden.

    Under 1% of code does tricky things. It is true that you will find non-trivial code in academic papers, maybe something like a cryptography research paper. Eventually that code will become something like openssl. But 99% of what you write will be simple database, GUI, or text processing work, or something else fairly mundane. That code is arguably much more important. The cryptography routine won't need much maintenance but GUI and database requirements change all the time.

    If you find yourself always writing mind-numbingly difficult code, perhaps you need to relax a little bit, because you won't make it 30 years.

  74. Can I get a "duh"? by Anonymous Coward · · Score: 0

    In short, it's good to make your code as simple and elegant as you can for the particular situation, while keeping it readable and maintainable -- which, ironically, in some instances may require more complex code, just so the solution is detailed enough to be understandable. Of course, no one wants to plague of "clever" solutions that are so read-only as to be unmaintainable. Simple as you can, complex as you need.

  75. Complexity and Bugs by martyb · · Score: 1

    Q: What's wrong with complexity?

    A: It hides bugs!!

    Notwithstanding that some tasks are inherently complicated and there's just no simple way to express it I would posit that the problem with unnecessary complexity is that it hides bugs.

    Bugs hide in the edges. They swarm in corners. They positively thrive in interfaces.

    Simple (i.e. clean) code helps make the bugs stick out.

    There is some business case or need behind each programming effort. That case/need has an underlying language, a grammar, that embodies what needs to be done and when and how. The challenge in software development is to find programming constructs which, inasmuch as is possible, clearly expresses the problem's solution.

    Through hard-won experience we've discovered things that suggest where bugs like to hide; what are sometimes called "Code Smells." Massive, nested IF statements. GOTO statements. Global variables. Side effects.

    But, these are only symptomatic. There are times when some of these ARE necessary to achieve maximum performance. In other words, not all cases are bad, but they suggest a long, hard look to ensure they are necessary.

    Consider programming languages. We started with machine code. Then we wrote assemblers to make it easier to express what we wanted to do. Then came macros and functions. Still later we developed higher level languages. All of these steps allowed us to more easily express what we were trying to do.

    Consider this continuum. Case 1: A single program with thousands of lines of code and no functions or subroutines. Case 2: The same application implemented with thousands of functions, each of which contain at most 5 lines of code.

    There's probably a sweet spot in between those extremes. A point where the abstractions of what needs to be done closely mimics the problem domain. Where the inputs and outputs are clearly delineated and checked. Where each function is the "right size". As the lowest level functions are implemented and tested, they provide a framework, a language in which one can more easily express what is being done. It is clear what is attempted and how. And it is clear when things are amiss. It makes the bugs "stick out."

    When we fail to do this, when we unnecessarily complicate the code, then problems arise. We struggle to grok the code. In this struggle, overwhelmed in trying to follow the "good" paths, we fail to see all its shortcomings. We provide hiding places for bugs. They blend in. They avoid observation. Or, when detected, resist eradication. For some samples, take a look here.

    tl;dr. Given: Some problems are just plain complicated and defy any further simplification. Fine. Other problems are amenable to consistent abstractions. When we fail to do that, we introduce unnecessary complexity. We breed bugs.

  76. need to spec appropriate level of robustness by Chirs · · Score: 2

    I work on highly-available systems (telecom equipment, core network stuff). Even there, some parts of the system can be less robust and some parts need to be as robust as possible.

    The design for a given component needs to take into account how robust that component needs to be. Do you check EVERY POSSIBLE error condition and figure out intelligent ways to handle them (can be quite difficult and very time-consuming) or can you just panic the system if you detect something has gone wrong and you don't know how to handle it?

    In some cases, you need to trade off between reliability and performance. In other cases you need to ship a product so it goes out with known corner cases that aren't handled because in the real world that condition should never happen.

  77. appropriate level of error handling by Chirs · · Score: 1

    While I'm generally on the check-for-errors case, I find that I generally don't have the time to test for every single documented error code and handle each one differently. I usually test for a few that I know I can deal with, and then bail out with loud log messages if the others happen.

    Something as simple as open() can spit out something like 22 separate errors. I generally don't check for each one separately.

  78. Elegant by Zaphod+The+42nd · · Score: 2

    There already exists a word for "no more complex than required", and that term is ELEGANT.

    Its been around since the beginning of programming. Get with the program. This is a non-story.

    --
    GCS/MU/P d- s:- a-- C++++$ UL++ P+ L++ E+ W++ N o K- w--- O M+ V- PS+++ PE Y+ PGP t+ 5- X R++ tv+ b++ DI++ D++ G+ e++ h-
    1. Re:Elegant by Anonymous Coward · · Score: 0

      Elegance is a concept in aesthetics. You can co-opt it into a mathematical role if you like, but only because words can be redefined. That is not the common meaning of the word elegant as applied to computer programs. "No more complex than required" is not even a pre-requisite for elegance - sometimes, adding slightly more complexity introduces symmetries which make the code more elegant. Not much more complex than required is a good rule of thumb pre-requisite, but it doesn't guarantee elegance, nor does breaking it guarantee inelegance.

  79. Clan, not necessarily simple by analogkid76 · · Score: 1

    In my 10+ years of experience in the field, I have learned and come to appreciate that it's important to strive for clean code. Simplicity is often a side effect, but you can model vastly complex concepts still in a clean way. To me, therein lies the art.

    1. Re:Clan, not necessarily simple by analogkid76 · · Score: 1

      Ugh, should have said "clean" - typing on a blackberry (let the mocking begin!)

  80. Occam's razor by StillNeedMoreCoffee · · Score: 1

    Occam's razor (also written as Ockham's razor from William of Ockham, and in Latin lex parsimoniae) is a principle of parsimony, economy, or succinctness used in logic and problem-solving. It states that among competing hypotheses, the hypothesis with the fewest assumptions should be selected. In other words, the simplest explanation is usually the correct one.

    Apply recursively to the created solution.

  81. Very true by Anonymous Coward · · Score: 0

    I guess there is a minimum level of complexity which can be achieved for a given task. You can make things unnecessary complicated and that is wrong. However, you cannot make complicated task (infinitely) simple. I experienced that trying to simplify my project and rewriting until I noticed I cannot simplify it anymore and it just has to be that complicated and built as an improvement on previous effort.

  82. Duh! by OneAhead · · Score: 1

    Amazing one can reach the /. "frontpage" these days by writing something this trivial (and having a big name). All TFA says is:
    - The complexity of a complex problem cannot be reduced indefinitely.
    - Code should strive to be as simple as possible but cannot be made to violate this law.
    I'd think anyone who has ever written complex code (like most science/engineering code, or a 3D game engine) should knows this from experience. Not to mention people with basic background in information theory and half a brain cell. If you're a programmer and you think "wow, that's a clever insight", then better get another job.

  83. " There is no inherent good/bad dichotomy." by Anonymous Coward · · Score: 0

    And this is where the supposed seasoned programmer shows his true bias and ignorance beyond measure to ensure that he's labeled a poseur for all time. To ignore any good or bad part of code is to exhalt bullshit programming practices.

    And you people listen to this ill-educated half-assed programmer of a fuck, why?

  84. My favourite quote by coder111 · · Score: 1

    This and exactly this. I have worked on quite a few systems in my life, and not once I have though "only if this system was more complex". Most of the time what I found was duplication, unnecessary abstraction layers, no separation of concerns, too much unnecessary flexibility, very roundabout and complex solutions to very simple problems. Usually I am able to refactor it into something that is ~5x smaller, and easier to understand, and faster, and easier to change.

    I hate it when people add flexibility and features in advance, and it ends up never used. And while Agile approaches seem a bit cowboyish sometimes, I agree with them on one point- implement the simple stupid solution first, make it more complex only when necessary.

    --Coder

  85. use a library by Chirs · · Score: 1

    Then it's a relatively few lines of code to do regex matching.

  86. that would be a great plan by Chirs · · Score: 1

    In the real world, plan to never be able to come back and refactor your code until the next feature that touches it.

  87. Another Car analogy with Compexity? by tyrione · · Score: 1

    Sorry, but gas mileage has not sored due to well written, but complex code. It has gotten of the ground [sored my ass] due to forced regulations. The Department of Energy asked every major auto manufacture in 1990 to be part of a DoE Engine efficiency project where everyone must submit a 90mpg automobile. They all did it. Not a single one exists on the market to this day. How come? They weren't forced to release them. They didn't reach improved Carnot engine cycles because of some embedded system: they used different composite materials in the engine block allowing doubling and more heat to burn the fuel more efficiently. End of story.

  88. Foo-King More-On by Anonymous Coward · · Score: 0

    It's morons like him that highlight the difference between programmers & software engineers - programmers require adult supervision.
    As long as software is coded like a wirewrap prototype, software folks will (rightly) get no respect.

  89. It's all moot by Anonymous Coward · · Score: 0

    Good code is complex in the background but looks simple when viewing through different lenses

  90. complexity, or lack thereof, reveals understanding by bigogre · · Score: 1

    I have been a software developer for about 30 years. I have written a lot of code and maintained a lot of code written by others.

    I have found that when I understand a problem I can reduce the complexity of the code I write; one measure being number of lines.

    I have read other people's code and been amazed by the simplicity possible when solving a complex problem.

    I have also gotten headaches from reading code that is very complex that doesn't need to be. Often such code came from self-educated software developers.

    Based on these experiences I came up with a maxim: The complexity of a solution is inversely proportional to the understanding of the person who created it. In other words, the better a person understands the problem to be solved the simpler the solution will be. That doesn't mean that a solution is simple, but it does mean that it is understandable. I have yet to encounter a situation, whether it be software, or organizational issues, or pretty much anything that people can do, to which this maxim does not apply.

    Another measure is can the developer explain the code? I have had developers tell me that I will never be able to understand the code they have written and then made no attempt to explain the code. All that communicates to me is that they do not understand what they wrote.

  91. Cut and paste to complexity by Anonymous Coward · · Score: 0

    Pretty easy to create complex code, hard as hell to maintain it.

  92. Comment removed by account_deleted · · Score: 1

    Comment removed based on user account deletion

  93. Complex or complicate code? by Anonymous Coward · · Score: 0

    Complicated code isn't complex code. Complex code is natural. In the realm of complexity, one can write complicate code or simple code.

  94. Fred Books, Mythical Man Month, 1975 by kevinsullivan · · Score: 1

    "... the ratio of function to conceptual complexity is the ultimate test of system design. Neither function alone nor simplicity alone defines a good design."

  95. It's not simple or complicated by Plebis · · Score: 1

    It's obfuscated or clear. I strive every day to write the clearest code possible, whether it's complicated or not depends on the problem I'm trying to solve.

    --
    "Dude, pounds are so metric, fuck that." - Noah
  96. All complexity can be made simple by geekoid · · Score: 1

    when broken into small parts as isolate from each other as reasonable.

    A car is complex, but you don't design it as one thing. You design each piece individually to be ut together withing a defined method for the vehicle.

    --
    The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
  97. Re:complexity, or lack thereof, reveals understand by geekoid · · Score: 1

    " Often such code came from self-educated software developers."
      think that's a bias, but I would love to see an actual study .
    The most overly complex code I have ever seen have been from MIT and Cal-Tech.
    The worst code I have ever scenes has been from self taught 'web masters' Worst in that they clearly didn't understand basic concepts of software.

    --
    The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
  98. Oh, the Shame... by whitroth · · Score: 1

    Has he also forgotton the original subtitle of the mag, "running light without overbyte"?

                    mark

  99. An appropriate Epigram from Alan J. Perlis by Anonymous Coward · · Score: 0

    Fools ignore complexity. Pragmatists suffer it. Some can avoid it. Geniuses remove it.

  100. True, but... by Anonymous Coward · · Score: 0

    It is indeed true that some problems are necessarily complex in code. Sometimes very complex. But I have seen so many examples of code that took much simpler problems and made them very complex. Sometimes just as an exercise in using all of the complexities of a language's features. I think this is what distinguishes the really good software developers from those that are not so good.

  101. the opposite of simple is not complex by peawormsworth · · Score: 1

    Simple code is harder to write, because it is hard to define. I dont know of any filter to put code into and get back a value on "the simplicity scale". That said, some code is easier to follow (read) and does not contain unnecessary variables and routines. In general, I would say that the shortest amount of code to accomplish the intended goal is the simplest... but there is a limit to this. One code may be easier to debug and reproduce errors and output important values during execution.

    When most programmers and debuggers look at 'complex' code... they are usually talking about the format and choice of loops and iterations. Or that the code has been upgraded and modified so many times, that the style no longer flows in a natural and readable way.

    In summary: simple code takes longer to produce because it all needs to follow a single style and it needs to be created with a mindset for future developers who will be upgrading and debugging the code. And the total logical flow of the program needs to be considered in order to reduce and remove useless iterations. It is easier and faster to modify existing code without these considerations. The resulting code of fast upgrades without consideration for future changes is what programmers sometimes call: spagetti code. It is spagetti code that I would suggest is what most programmers think of when they call some code "complex".