CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Jeremy D. Miller -- The Shade Tree Developer

Under the hood and working with .Net, TDD, Software Design, and Agile Stuff

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:

 



Comments

Isaiah said:

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

# May 28, 2008 6:55 PM

Bryan Reynolds said:

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

Its good to see more articles on it.

Bryan

# May 28, 2008 7:19 PM

John Papa said:

Nice article Jeremy, and congrats on the series overall!

# May 28, 2008 8:01 PM

Joe said:

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.

# May 29, 2008 1:22 AM

Reflective Perspective - Chris Alcock » The Morning Brew #103 said:

Pingback from  Reflective Perspective - Chris Alcock  » The Morning Brew #103

# May 29, 2008 3:10 AM

Colin Jack said:

@Joe

True indeed, layering definitely has disadvantages too.

# May 29, 2008 3:42 AM

Jeremy D. Miller said:

# May 29, 2008 8:14 AM

Mohan said:

Jeremy,

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

Congrats!

# May 30, 2008 9:59 AM

Paul Marshall said:

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.

# June 30, 2008 10:24 AM

Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add

About Jeremy D. Miller

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 previously worked as a systems architect building mission critical supply chain software for a Fortune 100 company and learned agile development practices as a .Net consultant at ThoughtWorks, one of the pioneers of agile development. Jeremy is the author of the open source StructureMap (http://structuremap.sourceforge.net) tool for Dependency Injection with .Net and the forthcoming StoryTeller (http://storyteller.tigris.org) tool for supercharged FIT testing in .Net. Jeremy's thoughts on just about everything software related can be found on his weblog "The Shade Tree Developer" at http://codebetter.com/blogs/jeremy.miller, part of the popular CodeBetter site. Jeremy is a Microsoft MVP for C#. Check out Devlicio.us!

Our Sponsors

This Blog

Syndication

News

All opinions expressed here constitute my (Jeremy D. Miller's) personal opinion, and do not necessarily represent the opinion of any other organization or person, including (but not limited to) my fellow employees, my employer, its clients or their agents.

About Me

"Best Of" Compendium

StructureMap (Dependency Injection for .Net)

StoryTeller (Supercharged Fit)

Build your own Cab

TestDriven

MVP