Justin du Coeur (jducoeur) wrote,
Justin du Coeur
jducoeur

  • 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
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 6 comments