The Open/Closed Principle on MSDN

My latest article entitled The Open Closed Principle is available in the June 2008 edition of MSDN Magazine.  I tried to present both the motivation for following the OCP and some design strategies (besides the obvious Plugin example) and related principles to bring your design closer to being “Open for Extension, but Closed for Modification.” 

If you’ve never heard of the Open/Closed Principle, think of doing an addition to an existing house.  What sounds easier, laying all new bricks for an all new room, or changing the layout of existing rooms with a reciprocating saw?  An Open/Closed design allows us to extend the system with new code instead of having to potentially screw up existing code that works today. 

Lastly, if you’ve read about the OCP before and think the OCP == “Plugin Pattern,” go give the article a read, because that’s not the entire story.

This is the first in a bi-monthly series of articles called Patterns in
Practice on software design fundamentals.  The next article (Object
Role Stereotypes/Responsibility Driven Design) is already completed, but I’d be perfectly happy to
take requests.  I think the next two leading candidates are “design
vectors” (i.e. better designed code by moving in the direction of this, that, or the other) and treating Inversion of Control as a design pattern
independently of IoC tools.

Related Posts to the Article:

 

About Jeremy Miller

Jeremy is the Chief Software Architect at Dovetail Software, the coolest ISV in Austin. Jeremy began his IT career writing "Shadow IT" applications to automate his engineering documentation, then wandered into software development because it looked like more fun. Jeremy is the author of the open source StructureMap tool for Dependency Injection with .Net, StoryTeller for supercharged acceptance testing in .Net, and one of the principal developers behind FubuMVC. Jeremy's thoughts on all things software can be found at The Shade Tree Developer at http://codebetter.com/jeremymiller.
This entry was posted in Design Patterns, Maintainability. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
  • http://www.eknacks.com/SingleListView.aspx?li=129 eKnacks

    You’ve been knacked. Keep up the good work.

  • http://www.wavecrestsoftware.co.uk Paul Marshall

    Great article.

    Whilst the MSDN mag is good for all things Microsoft, its good to read content about software design.

    Well written and informative.

    Look forward to the next installment.

  • Mohan

    Jeremy,

    You outdid yourself again. Looking forward to more gems like this in the future.

    Congrats!

  • http://codebetter.com/blogs/jeremy.miller Jeremy D. Miller
  • http://colinjack.blogspot.com Colin Jack

    @Joe
    True indeed, layering definitely has disadvantages too.

  • Joe

    Great article. I find this funny however:

    “What you want to avoid is to have one simple change ripple through the various classes of your application. ”

    And yet by layering our application, every single change like adding a new field will “ripple” through our entire application.

  • http://johnpapa.net John Papa

    Nice article Jeremy, and congrats on the series overall!

  • http://Bryan.ReynoldsLive.com Bryan Reynolds

    Just finished reading Agile Principles, Patterns, and Practices in C# (Robert C. Martin Series).

    Its good to see more articles on it.

    Bryan

  • http://isaiah.perumalla.wordpress.com Isaiah

    excellent article, cant wait for Object Role Stereotypes/Responsibility Driven Design