Design Pattern Evangelist Blog

Smart pointers about software design

It's Your Move

Do you know how to truly play the game, or do you only know the rules?


Chess Pieces

I learned the rules of chess when I was about eight years old. The rules fit on a single piece of paper that came with most chess sets. I could play the game casually with friends, but I was never really any good.

Fast forward 15 or so years, soon after starting my first job. I was in the bookstore at the local mall, and I spotted this book, The Logical Approach To Chess by Euwe, et al.

The Logical Approach To Chess Book Cover

I picked it up and thumbed through it. It wasn’t a beginner chess book. It wasn’t an advanced one either. There were no set up chess problems with prompts to find white’s move to force checkmate in 20.

In the first dozen pages I learned the importance of the center squares with great analogies, such as the Strait of Gibraltar and the Panama Canal. Surrender the center squares to your opponent, and you’ll be in a fine pickle of limited mobility. They listed opening position goals such as: develop your minor pieces, i.e., get your knights and bishops off the back rank, and connect your rooks on the back rank. The advice continued through the middle and end game as well. True to its title, it made logical sense.

I felt as if the scales had fallen from my eyes. I had been playing this game poorly for years. I only knew the rules. But now I knew the techniques of how to play well. My game improved appreciably from this book.

Fast forward another 15 years or so again. I had been a C developer and a C++ developer for the previous five years or so. I understood the elements of Object-Oriented Programming such as encapsulation, inheritance, polymorphism, etc.

I had heard of “Design Patterns” in the mid-1990s. I had even attended a few technical presentations, but they never held my imagination. By 2000 I was working at a startup and some developers mentioned design patterns off and on … mostly Singleton. A coworker had a copy of the Gang of Four Design Patterns Book on his desk.

Design Pattern Book Cover

I was curious, and I asked if I could borrow it. He obliged.

I tried. I really tried. I started reading it two or three times, and at around page 80 I was completely lost. Being a startup, we were working 50-60 hour work weeks, and I just didn’t have time to do a deep dive into the book and figure it out.

Then I took an unplanned eight-month sabbatical sponsored by the New Jersey Department of Unemployment when our startup imploded in the early 2000s in the era of the dot-com bubble burst. I had all the time in the world, but I didn’t have the Gang of Four book. That was a blessing.

I turned to the internet. I found a very useful page on Wikipedia: Software Design Pattern as well as a few follow up sites. I was taking a Java course at a local community college as well, so this became a perfect opportunity to learn design patterns and Java together.

Once more I felt as if the scales had fallen from my eyes. I had been programming in C++ poorly for years. I was following the rules of the programming language but without good Object-Oriented design. But now I knew some techniques of how to design in OO. My software improved appreciably from this knowledge – fewer mysteries, fewer errors, and fewer late nights.

Learning design patterns during those months of unemployed was the best investment I made in my career outside of my college experience.

If you haven’t found the time to learn design patterns, try and carve out some time. I’ll be blogging about them, but here are a few good resources to start.

I recommend the Gang of Four Design Pattern book once someone already has a solid grasp of design patterns. I recommend Head First Design Patterns as a primer.

Head First Design Patterns Book Cover

It covers 15 of the original 23 design patterns, and it covers them with good descriptions, diagrams, code examples and humor. Had the authors covered all 23, I suspect the book would have been too heavy to lift.

Here are my favorite online design pattern resources:

The first two sites are related, so there’s some duplication. Both sites also have great resources on Refactoring and Code Smells.

Comments

Previous: Knock, Knock ... Who's There?

Next: Problem Solvers

Home: Design Pattern Evangelist Blog