This is a post about a book, yes a book. One of those paper things I hoard in my shelf. More specifically this one called "A philosophy of software design" by John Ousterhout.
So I finally made it though after having had it in my possession for.. checks mailbox ...11 months. Wow. However that really says more about me than it does about the book.
It is a book about complexity, it describes and exemplifies it in a nice manner. Many of these things are stuff you develop a gut feeling for over time, and is difficult to get in writing, but the author puts it very well into words.
I'd recommend everyone involved in development read it, but I'll summarize my favorite take-aways below.
- Think and act strategically and long term. This will allow you keep the momentum going and not slow down and want to give up. This goes both for green field and legacy projects.
- Make stuff a little more generic than it has to be right now. It won't be long before someone copy and pastes your
ReadConfigFromFile()
function just to read a different file. - Define errors out of existence. Firstly, modeling: What are the consequences of modeling your chess board as a linked list of pieces? It's rather easy to end up in a situation with multiple pieces on the same tile. But if you model it as a 2D array of tiles, each of which holds an
Option<Piece>
, you're good. This doesn't prevent you from having the board full of kings, but hey. Secondly, about semantics: If you have a function that changes some state. Maybe aremove
function which makes a file go fromexists
todeleted
. Or a networking function that takes you fromconnected
todisconnected
. You can either have it fail if the file is already removed - or you just say "it ensures that the file is removed", so callingremove
on a file that's no longer there is a no-op. You've saved your users from a lot of headache by defining the semantics of the function to remove error cases.
At less than 200 pages, this book is a given for anyone who can get their hands on one. (The book is still not available on Adlibris)