This slim volume, the first of a series, is for professional programmers–that breed of software developers with a deep and geeky interest in their craft and in improving their work in small ways with big payoffs. The author, Kent Beck, is just such a dedicated professional, ever attentive to detail and ever in tune with the larger issues and the bigger picture.
Practicing software developers often pay scant attention to theory, but Kent knows what he is talking about when he mixes practice and theory into a guide to tidy code that is both readable and practical.
In theory, there is no difference between theory and practice, while in practice there is. Various versions of this pithy pronouncement have been widely and incorrectly attributed to Albert Einstein and Yogi Berra, among others. Only a nerdy wordsmith (guilty as charged!) would care that the correct attribution is to Benjamin Brewster, a student at Yale writing in an 1882 edition of the Yale Literary Magazine. Thanks to the dedicated word geeks at QuoteInvestigator.com, I can offer this bit of geeky detail confident of the audience here: this is a profession that hinges on getting the details right.
In bringing theory and practice together, Kent starts at the bottom, with tiny snippets of code and meticulous attention to small details, then works his way up to the larger view that explains the process of creating cleaner code that is more robust in the face of inevitable changes and corrections. In assembling this guide to practice, Kent ultimately draws on the real-world economics of software development along with core theory in software engineering.
That core theory is simply this: that the complexity of computer code depends on how it is organized into parts, on how coupled those parts are with each other and on how cohesive the parts are in themselves. The source of the theory of coupling and cohesion is usually attributed to my book with Ed Yourdon, Structured Design (Yourdon Press, 1975; Prentice Hall, 1979), although it can be traced all the way back to a 1968 conference presentation in Cambridge, Massachusetts. Coupling and cohesion almost didn’t make it into the 1979 Prentice Hall edition. The editors tried to convince Ed and I to omit the two chapters because “no one is interested in theory.” Fortunately for the history of software engineering, the authors prevailed and the editors were proved wrong. The theory has since been validated through a half century of practice and literally hundreds of research studies and investigations.
Coupling and cohesion are simply measures of the complexity of computer code, not from the perspective of the computers executing the programs but that of human beings trying to understand the code. To understand any program, whether to create it or to correct it or to change it, requires understanding the piece of code immediately in front of you as well as those other pieces to which it is connected, which it depends on or affects or is affected by. It is easier to understand the immediate piece of code if it all hangs together, if it makes sense as a whole, if it forms what cognitive psychologists call a gestalt. That’s cohesion. It is also easier to understand it in terms of its relationships with other pieces of code if these relationships are few and relatively weak or highly constrained. That’s coupling. Coupling and cohesion are really all about how your brain deals with complicated systems.
See? Nice and tidy. That’s the theory. Now on to the practical details and the mix with just enough theory to make sense of it all. Kent Beck will ably guide you on the way.
Larry Constantine is a former professor at the University of Madeira, Portugal, and the University of Technology, Sydney, Australia. He has more than 200 papers and three dozen books to his credit, including the Jolt Award winner, Software for Use (Addison Wesley, 1999), written with Lucy Lockwood, and fifteen novels under his pen name, Lior Samson.