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.'"

9 of 381 comments (clear)

  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 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
    2. 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.

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

      Clearly, not taking his own advice here...

    4. 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.

  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...

  3. 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.

  4. "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
  5. 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.