Duplication is the Root of All Evil
Dec. 30th, 2008 06:26 pm![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
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.)
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.)