Smalltalk Best Practice Patterns: Part One
Anyone can pick up a book on Object Oriented Programming and learn all about encapsulation, inheritance, composition, polymorphism, and other typical OO concepts. Learning the concepts doesn’t make you a good OO designer/programmer. You can spend years reading other people’s code and gleam a few nuggets of knowledge. Over a career, you finally feel that you get OO programming and feel competent in it.
Or, you can just read Smalltalk Best Practice Patterns by Kent Beck and get a jump start on that. It’s interesting that a book published in 1996 and never updated can still be so relevant for today’s world. It’s listed first as DHH’s top five programming books and well deserved in that spot.
Reading the book now, it’s easy to see the impact its knowledge has subsequent languages and frameworks.
By the way, it help to have some grounding in Smalltalk before reading the book. You don’t have to be fluent, but a couple passes through Smalltalk syntax certainly helps.
Intro
Right there in the intro, Kent already made clear many of the concepts we now take for granted.
- Once and only once - DRY
- Lots of little pieces - modular design and decomposition
- Replacing objects - The “L” in SOLID
- Moving objects - again, modular design that enables reuse
- Rates of change - don’t mix and match parts that changes often with parts that don’t change. I see this as a mixture of the “S” and the “O” in SOLID
This is before we even get started into the main book.
Patterns
The book defined 92 patterns separated into the following categories
- Behavior
- State
- Collections
- Classes
- Formatting
Of these, the least relevant are the ones around “Formatting” since there are a lot specifics about Smalltalk formatting. The “Collections” section almost serves as a nice historical document as any current language has well-implemented Collections library and matches well with what’s described there.
On Java
Reading through the book, it’s easy to see the design advantages of anonymous function in Smalltalk. All the more galling that it’s not available to Java until Java 8 was released in 2014. Smalltalk was released in 1972!
In the next part, I will talk through some of the patterns that really struck a chord with me.