Loading ...
Sorry, an error occurred while loading the content.

What is Good Code?

Expand Messages
  • Gary Brown
    I had an interesting conversation with one of our young guns the other day. We are not as good or as merciless at refactoring as we need to be, so I sent out
    Message 1 of 154 , Apr 5, 2007
    • 0 Attachment
      I had an interesting conversation with one of our young guns the
      other day. We are not as good or as merciless at refactoring as we
      need to be, so I sent out a refactoring challenge to be done during
      personal development time. The task was to improve the readability
      of a very smelly implementation of the bowling game.

      This developer and his partner redesigned the code from the
      traditional procedural loop, to a more object-oriented node
      traversal scheme. It passed all of the tests, but it was pretty
      hard to find bowling in there. They went from a procedural design
      that didn't reveal its intent to an object-oriented design that
      didn't reveal its intent.

      When I showed them the winning submission, one of the developers
      went off on a rant about how much better his object-oriented version
      was than the procedural version. I said that it doesn't reveal its
      intent. He went on about how his version used less memory and
      executed the tests in half the time. I again reminded him that the
      point of the exercise was to improve the readability of the example,
      so that it clearly revealed it intent. Then it got personal. He
      reminded me that I am old, fat, and stupid, among other things.

      Once he calmed down (and his nose stopped bleeding 8^)) we talked
      about the evolution of what we should value in our code. There was
      a time when computers were expensive and programmers were cheap.
      Clever algorithms that ran fast in the smallest possible footprint
      were highly valued. The trouble was that such code was difficult to
      extend and maintain, except by (and even often by) the original
      author.

      Many innovations have come since then, structured programming,
      relational databases, object-oriented programming, design patterns,
      test-first programming, and of course Moore's Law. Now, computers
      are cheap and programmers are expensive. The efficiency of the
      people is much more important than the efficiency of the code.

      Code that clearly reveals its intent is easier to enhance and
      maintain. It allows us to deliver more value to our customers in
      less time. We need to apply our skill and creativity to writing
      code that anyone can understand. To me, that is the new definition
      of good code.

      GB.
    • William Tozier
      ... Can t resist: Now is the funny word in that sentence. ... Bill Tozier AIM: vaguery@mac.com; Skype: vaguery; Twitter: Vaguery
      Message 154 of 154 , May 2, 2007
      • 0 Attachment
        On May 2, 2007, at 5:58 AM, Elizabeth Keogh wrote:

        > I think you're being picky now.

        Can't resist: "Now" is the funny word in that sentence.
        -----
        Bill Tozier
        AIM: vaguery@...; Skype: vaguery; Twitter: Vaguery
        thttp://williamtozier.com/slurry

        "People who write obscurely are either unskilled in writing or up to
        mischief."
        -- Sir Peter Medawar
      Your message has been successfully submitted and would be delivered to recipients shortly.