Justin du Coeur (jducoeur) wrote,
Justin du Coeur

  • Music:

Duplication is the Root of All Evil

The Initiate looks at two methods that share six identical lines of code, and says, "Were I to pull these into a common method, it would be a Benefit."

The Journeyman looks at two classes that are doing roughly the same things, and says, "Were I to lift out a common class, and isolate the differences to listeners, it would be a Benefit."

The Master looks at two programs that are structurally similar, and says, "Were I to pull out these patterns and turn them into a generics-based framework for both programs, it would be Really Cool. (And a Benefit.)"

The Novice looks at an example class, sees that he wants to do something similar in a new class, and copies all the code from the first to the second, changing a few lines where they're different. The Master looks at this, and bangs his head against the wall.

(This parable brought to you by my second straight day of refactoring, to clean up the mess that my data model layer has become. Not that I've been making Novice errors, but suffice it to say I am now regretting that I didn't formalize my DOM from the outset, and I'm fixing it before the ad hockery gets out of control.)
Tags: programming

  • The Third Way: Beyond Fun and Authenticity

    I just came across this marvelous essay on the SCA fun/authenticity false dichotomy, and a different way of looking at it. It was written some…

  • Fairy Lights

    One surprising highlight from 50 Year doesn't seem to have made it into many accounts -- I think our encampment was particularly well-placed in this…

  • Animal-friendly events are just *different*

    (As usual for when I've attended something long, I'll be posting some random reminiscences.) Being held at a 4-H Fairground, SCA 50th Year was just…

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded