...And I hope that someday
That you, you people will all have the chance
To read The Helping Friendly Book
And experience the wisdomOf the great, the great and knowledgeable
Man who wrote The Helping Friendly Book
Because he is, the great and knowledgeable
He is the one, the only author of The Helping Friendly BookHe is the man
The great man
The only, the special
His name isThe author of The Helping Friendly Book
He is the great
The knowledgeable, the one and the only
The great, the knowledgeable
Person who wrote The Helping Friendly BookHis name could only be
The one, the only, the only, the special
The author of The Helping Friendly Book...
-Excerpt from Icculus by PhishThere are few mantras that are as universally agreed upon by Software Engineers as Don't Repeat Yourself or DRY. It rings deeply and globally true that any form of code duplication is at best a compromise, at worst, an abominable trap. Writing and maintaining code is difficult enough without doing it many times. So if we all know this, and we all agree, then why is it that the industry's preferred architectural best practices embrace duplication?
If you've ever built a controller, a repository, a service layer, a data access provider, or anything remotely like one of these things, you know exactly what I'm talking about. Duplication is what you do. You copy the logging code. You copy the query strategy. You copy the update methodology. You copy the attributes and data structures. You copy the exception handling pattern. "That's how it was shown to you by smart people, so it must somehow be right," you think as you faithfully type away, all the while wondering if you've become little more than a digital version of a truck driver.
Like the proverbial cliff all your friends jumped off of according to your mother, it doesn't matter how bad of architecture you have seen, there is another, better way... so stop it! But perhaps you're so used to following your lemming-like friends that you don't know how to escape the allure of duplication? I'll offer some suggestions.