October Meeting – The Open/Closed Principle

This month’s meeting will be on Thursday, October 13th at 6:00pm. A special thanks to our host this month, Cellular Sales! And, as usual, many thanks to our sponsor, TEKsystems! They’re having Salsarita’s cater our meeting – YUM!

We’re going to be focusing on the ‘O’ of SOLID – the Open/Closed Principle. The principle states that a class (or module or function) should be open to extension but closed to modification. Sure, we should follow this principle, but do we really? All the time? What would happen if we did follow this principle strictly, even if it is just for a kata? That’s what we’ll find out this month.

This meeting will start with a round-table discussion about OCP, then we’ll see a quick demonstration of an OCP kata on the projector. Then everyone will pair off and do their own OCP kata. It should be interesting to see what our designs look like.

So, what is an OCP kata? It begins like any other kata, by writing a failing test. From there, the process diverges:

0. Write the first failing test. Then write a factory that returns an object, or an aggregate of objects, that make the test pass.

The factory should be limited to creating objects and linking them together. No conditionals allowed.

1. Write the next failing test.

2. Can you make it pass by changing the factory and/or creating a new class and nothing else? If yes, great! Go back to 1. If not, refactor until you can.

The refactoring should bring the system to a state where it’s possible to implement the next test just by changing the aggregate of objects that is returned by the factory. Be careful not to implement new functionality; the current test should still fail.

That should be enough to think about. Come to the meeting for more OCP goodness! And don’t forget to bring your laptop!

[rsvplink event_id=1]Click here to RSVP.[/rsvplink] (TEKsystems needs to know how much food to order).

[whoscoming event_id=”1″]


The meeting will be held at Cellular Sales’ office. Their address is:

311 Directors Drive
Knoxville, TN 37923 (map)

From Cedar Bluff, turn onto Cross Park Drive. Look for a Verizon Wireless sign across from the post office, then turn right into the parking lot at this green electrical box.




Leave A Reply

You must be logged in to post a comment.