Genre: Best Practices
Looking for some books focusing on the fundamentals of creating software, I saw a tweet by DHH recommending this one by the wekk renowned Kent Beck. I wasn’t sure that a book for the Smalltalk language would provide much use so I checked out the reviews on Amazon.
Most of the reviews for this book on Amazon were pretty good. There were a number of 4 & 5 star reviews coming from people from other languages – including C# - who stated this book was great at teaching the fundamentals.
With all that in mind, I felt I would give it a shot and I was also excited to see what the Smalltalk language was like. In the end, I don’t think it was quite 5 star – but it was a useful read.
There are 200 pages, spanning 8 chapters of this self-styled “style guide” to help beginners learn “the simple things experienced, successful Smalltalkers do”. And to be fair, the book is like a style-guide or maybe a patterns book, as the book is just a collection of patterns, grouped into related chapters.
A number of the principles in the book are really useful to any language. As an example, page 21 has the “Compose Method” behaviour. Kent Beck explains how one single method would be the fastest way to execute your application… but the hardest for a code monkey to understand. So you need to break things down into small methods with intention revealing messages.
Another is the value of properties – should you assign property values in the constructor? Or maybe have a “backing field” (in C# terminology)? Kent isn’t prescriptive about on or the other, in fact he has two patterns – explicit initialization and lazy initialisation, which both have pro’s and con’s. I think that is the essence of this book – pragmatic trade offs.
One final favourite applicable to all languages is the “Boolean Property Setting Method”. This principle is all about encapsulating state and thus not leaking those implementation details. Again, this exemplifies the philosophy of this book.
Naming variables to suggest their type is not restricted to Smalltalk, but probably is more aimed at dynamic languages. However, chapter 5 – titled “Collections” - is all about the collections available in the Smalltalk language.
In some cases, advice such as “Use a SortedCollection. Set its sort block if you want to sort by some criteria other than <=” will have little value to a C# developer. Likewise, the instructions on how to implement queues using an ordered collection will be equally of little value.
Developers who treat the OO paradigm as an opportunity to exhibit their procedural coding “skillz” will learn a lot from this book. Likewise, those who are self-taught or have never learned about good OO principles and readable code will improve by at least 20% if they apply what Kent Beck tries to teach them.
I’m no expert, so I definitely picked up quite a few things from this book. I even had plenty of fun learning bits and pieces about the Smalltalk language in the process. But there were also a few irrelevant pockets that provided me no real value.
For developers who know good OO and clean code, this isn’t essential reading. For anyone else, you should read this or a similar book in my opinion.