Published: 2008
Publisher: Addison-Wesley
ISBN: 0-321-41309--1

"Patterns" has become a bit of a buzz word in software development of late.  Kent Beck takes a different angle on the topic with his book "Implementation Patterns".  Beck takes the notion of patterns from being a somewhat abstract discussion of object oriented design down to the "bare metal" of the writing of the code itself.  In my opinion, every programmer ought to read this book, even if they don't follow his advice.  The ideas and concepts explored are critical to a deep understanding of what it means to develop software 

The Life of a Program

In the second chapter, Beck lays out a small set of "laws" that most programs follow:

  • Programs are read more often than they are written
  • There is no such thing as "done".  More investment will be spent modifying programs than developing them initially
  • They are structured using a basic set of state and control flow concepts
  • Readers need to understand programs in detail and in concept.  Sometimes they move from detail to concept, sometimes from concept to detail. 

These laws lead to a set of values and practices that lead to code that is easy to read and understand and is also easy to modify on the micro level.

Values

Communication - Code should communicate to the next person who comes along.  It should be easy to read, almost like a story.

Simplicity - Simplicity is in the eye of the beholder.  It must be applied at all levels, code formatting, design and requirements.  It means eliminating the unecessary.

Flexibility - You often find yourself balancing flexibility with simplicity as flexibility often creates complexity.  Knowing where things are likely to change can help choose the right place to land on the continuum.

Principles

Local Consequences - Structure code so that changes have local consequences.

Minimize Repetition - The fewere copies of code there are, the fewer places there are to change if that snippet changes.

Logic and Data Together - Decide whether to move the data or move the logic but keep them together.

Symmetry - For readability, making methods read with symmetry can be invaluable.  So if there is an OpenConnection() there should be a CloseConnection() closely following. 

Declarative Expression - Imperative programming forces you to follow the thread of execution to understand what it does.  In places where the program is more like a simple fact, declarative programming can lead to quicker understanding of the intent.

Rate of Change - Data or logic that changes at the same rate belongs together. 

General Notes

I won't list out all of the patterns that Beck gives in his book, suffice it to say that his book is so well written that it is a "must have" for a programmers library.  It is succinct and laid out as an easy to use reference without reading so dry. 

Here are a few quick notes I wrote down while reading the book:

  • Use one word names for important classes
  • Value objects should be immutable.  Use them only when state should not change.
  • Query method.  If one object needs to know the state of another, the logic is probably mis-placed. 
  • Collections.  The "rule of thumb" has been "use the most general collection that you can" but in practice it usually reads better if you don't.

Speaking of collections, if you are like me and didn't get a lot of data structures classes in college, you probably have struggled with all the different collections classes available in both Java and C#.  If so, the chapter on Collections in this book will prove a valuable resource for you.  Beck does an excellent job of explaining the import distinctions between the different types of collections.

Conclusion

I purposely did not include much of the material that I might normally archive in one of these "reviews".  My reasoning is that just in case you are reading this as a book review, you definitely should buy the book.  If you are reading it because you came across a term and want to know more about it, you should definitely buy the book.  The book is short and simple and contains an incredible amount of good information.  You should buy the book!