Conversations I’ve had with Code
Learning how to talk with other developers, through time, with code
Occasionally, I read something that instantly becomes a permanent and prominent memory. This was the case when I read a section of Chapter One in “Smalltalk Best Practice Patterns” (SBPP) by Kent Beck titled “Talking Programs.” I first read SBPP in the late 1990s, while I was a Smalltalk programmer. I have recommended this book to developers who work in any programming language for over twenty-five years.
I like reading books that make me think. I really like books that show and explain to me things that have been staring me in the face, without me even noticing them. You can look at SBPP as a way to learn how to become a better Smalltalk developer, or you can look at it as a book that can help you recognize and identify patterns, to help you become a better developer in any programming language.
Talking Programs and Good Software
In the section of SBPP, Chapter One, titled “Talking Programs”, Kent wrote the following question, which surprised me.
Did you know that your program talks to you? I don’t mean those “Buy more Jolt Cola messages. I mean important stuff about how your system ought to be structured.
-From “Talking Programs” in Smalltalk Best Practice Patterns, Kent Beck
The first time I read this, I thought “So that’s that voice I’ve been hearing!” Many of us are aware of the only metric in software that matters — WTFs per minute. That’s your program talking to you!
The conversational style Kent starts this section off with has become something I expect and enjoy reading in many of his books. I don’t know if this brief passage will make you feel differently about code. It’s had a lasting impact on me since the first time I read it.
I can tell right away if a developer is crafting a conversation in code for the next developer, or if they are just typing quickly to get stuff done. Many developers are more concerned with the transactional now (make it work), and less concerned with the conversational later (make it right).
In the section of Chapter One titled “Good Software”, Kent writes a profound statement which cuts to the chase.
If there’s a radical thought here, that’s it; that when you program, you have to think about how someone will read your code, not just how a computer will interpret it.
-From “Good Software” in Smalltalk Best Practice Patterns, Kent Beck
Before I read SBPP in the late 1990s, I thought I was writing code for the computer, not other developers. Writing code that works is one thing, and a lot of people can do that. Writing code that reads and communicates intent clearly is another. Your code is a persistent conversation you are having with all the developers who were there before you and come along after you, including yourself. While coding you should think how best to change the conversation to suit the current needs of the users of the system, while communicating the intent clearly to future developers of the system. Code is a communal conversation which evolves and will be read over months, years, or possibly even decades.
Code like you are telling a story
I’ve told developers who I’ve worked with that over the years that when we work on a project together, we should think of our system as a story we are writing together. If we learn from each other, communicate regularly, and establish and continuously refine code writing practices and style (e.g. good tests, formatting, naming, method size, symmetry, regular refactoring, etc.), then we might be able to write a story that looks like it was written by one consistent person, instead of by 5, 10, 20 different authors with different styles. Whether a team’s coding story becomes a non-fiction novel, a science-fiction/fantasy, or a murder mystery depends on how well the team communicates while they are collaborating.
The next time you are working on code, listen closely. The code will tell you when something doesn’t feel quite right. Take time to work on refactoring with your team until everyone is satisfied with the evolution of the story you are writing.
Thank you for reading!
I am the creator of and committer for the Eclipse Collections OSS project, which is managed at the Eclipse Foundation. Eclipse Collections is open for contributions. I am also the author of the book, Eclipse Collections Categorically: Level up your programming game.