The Don't Repeat Yourself principle is important. But it's not the only important principle or consideration for software design. Like all good things it should be used with caution and afterthought.
Today I attended an excellent workshop about Scala development held by Ted Neward. During the session Ted demonstrated a different, functional, aspect of the Inversion of Control concept which he illustrated in Scala. Since it’s fully possible to do the same thing in C# I thought would borrow and modify his example to show a different type of Inversion of Control.
The Open/Closed principle says that we should strive to write code that doesn’t have to be changed every time the requirements change. Here's a simple example.
An introduction to Inversion of Control, using the Dependency Injection and Service Locator patterns, along with simple examples in C#.
Out of the five SOLID principles the Open/Closed Principle is probably the one that I’ve had the hardest time understanding. However, a while ago though I found some code that I had written years ago that made me think to myself “Hey, this is clearly violating the Open Closed Principle!”.