Pile O'Patterns

Clean Code, Episode 32

By Robert C. Martin

68 minMay 2015

OK, so now we're really starting the make progress through the design patterns. In this episode we'll study five of the most useful.

First we'll discuss Singleton and Monostate; two patterns that help you enforce that only a single instance of a class is created.

The real challenge with these patterns is how you initialize the static variables that are involved. So we'll walk through the whole nine yards of initialization issues, including threading issues, locking, double-checked locking, etc.

You're going to love Monostate. It's a really cool pattern with lots of very interesting uses.

Then we'll talk about nothing. Or rather, objects that do nothing -- or rather objects that get away with doing nothing by doing nothing in just the right way. The pattern is called: Null Object.

Then, it's on to the Proxy pattern. This is the pattern used by most interprocess communication tools, and database isolation tools. Proxy is a pattern that is used when two objects need to communicate across a boundary, and should not know about that boundary.

Lastly, we'll discuss the Decorator pattern. Decorator is a member of the Visitor family of patterns. It is another way to add new behaviors to existing class hierarchies without modifying those hierarchies.

And after that we'll take a long deep breath to get read for the next episode -- and even more patterns.