Book Notes: The Art of Readable Code by Dustin Boswell

Published on: 2017-02-28

I highlight and take notes when I read nonfiction books. Once I finish a book, I format and edit my notes so that I can easily remind myself of what I learned without having to reread the book. These notes are not a substitute for reading the book, they only serve as a reminder of key concepts.


The fewer lines a variable is in scope, the shorter its name is allowed to be. Variables used in larger scopes must be less ambiguous so they are allowed to have longer names.

Don’t use project specific abbreviations — someone new to the project won’t know what they mean. “So our rule of thumb is: would a new teammate understand what the name means? If so, then it’s probably okay.”

“The clearest way to name a limit is to put max_ or min_ in front of the thing being limited.”

“In general, adding words like is, has, can, or should can make booleans more clear.”

“The best names are ones that can’t be misconstrued — the person reading your code will understand it the way you meant it, and no other way.”

“Everyone prefers to read code that’s aesthetically pleasing. By “formatting” your code in a consistent, meaningful way, you make it easier and faster to read.”

“The purpose of commenting is to help the reader know as much as the writer did.”

More comments aren’t necessarily better — the comments take up valuable screen real estate, so if there is a comment in the code “it better be worth it”.

“Don’t Comment Bad Names — Fix the Names Instead”

“Instead of minimizing the number of lines, a better metric is to minimize the time needed for someone to understand it.”

“The simplest way to break down an expression is to introduce an extra variable that captures a smaller subexpression. This extra variable is sometimes called an “explaining variable” because it helps explain what the subexpression means.”

“One technique [to clean up code] is to see if you can solve the problem the “opposite” way. Depending on the situation you’re in, this could mean iterating through arrays in reverse or filling in some data structure backward rather than forward.”

In general, keep scopes short and finish tasks as quickly as possible.

“The more places a variable is manipulated, the harder it is to reason about its current value.”

“The advice for this chapter is to aggressively identify and extract unrelated subproblems. Here’s what we mean: Look at a given function or block of code, and ask yourself, “What is the high-level goal of this code?” For each line of code, ask, “Is it working directly to that goal? Or is it solving an unrelated subproblem needed to meet it?” If enough lines are solving an unrelated subproblem, extract that code into a separate function.”

“Code that does multiple things at once is harder to understand. A single block of code might be initializing new objects, cleansing data, parsing inputs, and applying business logic, all at the same time.”

Break code up into small, easy to understand fragments. This makes understanding easier and reduces potential for bugs.

“do only one task at a time.”

“When explaining a complex idea to someone, it’s easy to confuse them with all the little details. It’s a valuable skill to be able to explain an idea “in plain English,” so that someone less knowledgeable than you can understand. It requires distilling an idea down to the most important concepts. Doing this not only helps the other person understand but also helps you think about your own ideas more clearly.”

“This chapter discussed the simple technique of describing your program in plain English and using that description to help you write more natural code. This technique is deceptively simple, but very powerful.”

“Knowing when not to code is possibly the most important skill a programmer can learn. Every line of code you write is a line that has to be tested and maintained. By reusing libraries or eliminating features, you can save time and keep your codebase lean and mean.”

“When you start a project, it’s natural to get excited and think of all the cool features you’ll want to implement. But programmers tend to overestimate how many features are truly essential to their project. A lot of features go unfinished or unused or just complicate the application.”

Thanks for reading. You might also enjoy following me on Twitter.

Want to learn even more SQL?

Sign up for my newsletter to receive weekly SQL tips!

Epic Life Quests

Published on: 2017-01-03

It is easy to get caught up in the daily details of life and not take the time to reflect on longer term goals and accomplishments.

Inspired by Brent Ozar and Steve Kamb, these Epic Life Quests are intended to help me reflect on my accomplishments and help me stay focused on the things that are important.

Each level contains five achievements and once all are completed I can “level up” to the next five. Follow along and let me know if you create any epic life quests of your own.

Level 2 (currently working on)

  • Blog weekly for 6 months straight — Last year I began blogging more than any previous year, but I didn’t always stick to a schedule. My biggest problem was I didn’t know what I wanted to write about so choosing topics was difficult and frustrating. After looking back at what posts were the most well-received, I’ve decided to focus the first half of 2017 to mostly technical and professional development type topics.
  • Speak at a technical conference — I’ve been presenting technical content in small user group type settings for years but this year I want to try my hand at some larger audiences. Completed January 2017 at the GroupBy conference.
  • Vacation in Hawaii — Our vacations in 2016 focused on places we could reach by car so that we could save some money for a larger trip. This will be the bigger trip. After visiting Hawaii, I will have visited 36 states + Washington D.C (airports don’t count!).
  • Work on mental mindfulness— practice meditation to improve focus, patience, manage stress, be happier. I want to average at least 5 days/week for 3 months to reach this goal.
  • Always be reading at least one book — Although I read 40+ books in 2016, there were stretches of weeks at a time where I was not reading anything. For 6 months I don’t want to go more than 3 days without having picked a book to have available to read.

Level 1 Quests (completed before 2017)

Here are some of my achievements before I started this page on January 1, 2017.

  • Set up an environment for programming regularly at home — completed 2016
  • Start using GitHubt for my coding projects — completed 2016
  • Built a hardware project that gets regular use (not just proof of concept) — completed 2016
  • Buy a house — completed 2015
  • Get into backpacking — completed 2015
  • Take a car trip in Europe with Renee — completed 2015
  • Learn to read books for pleasure — completed 2014

Thanks for reading. You might also enjoy following me on Twitter.

Want to learn even more SQL?

Sign up for my newsletter to receive weekly SQL tips!

My Year in Books 2016

Published on: 2016-12-22

Shocker: they aren’t all self-help or by Stephen King.

My GoodReads Year in Books

This year I read/listened to about 41 books (“about” because I didn’t finish a couple of them and because I still have a week and a half left to finish a couple more). I mostly read non-fiction, self-help, and horror fiction. Below are some of the more memorable reads from this year.

Code by Charles Petzold

Code: The Hidden Language of Computer Hardware and Software — Charles Petzold

If you have ever been interested in how the nuts and bolts (bits and bytes?) of computers work, this is the book to read.

Petzold starts out describing data transfer via tin cans and string and quickly moves you on to telegraphs, relays, binary logic gates, etc.. until the end of the book when you have “built” a model computer with full features like memory and an assembly language.

I think the book is targeted more towards a lay-person with interest in computers, but it is a fun read regardless of your technical ability as long as you are willing to think while you read.

Shenandoah by Sue Eisenfeld

Shenandoah: A Story of Conservation and Betrayal — Sue Eisenfeld

I’m not a huge fan of reading history unless I can directly relate to the subject matter. In this case, I read Eisenfeld’s Shenandoah right before our camping trip to Shenandoah this year.

What’s interesting about Shenandoah National Park is that unlike its cousin parks out in the western United States, Shenandoah became a national landmark long after the land area was already inhabited by people. This means that if you visit the park today, you can find remnants of roads, cabins, cemeteries, and orchards all throughout the park.

This book looks at the history of the people of Shenandoah before the land became a park and the lasting effects that it has had on the United States.

Never Split the Difference by Chris Voss

Never Split The Difference: Negotiating As If Your Life Depended On It — Chris Voss

Never Split the Difference is probably the best “self-help” book I read all year. You can find my notes on it in this previous post.

Voss was a master negotiator with the FBI, often helping negotiate for the lives of hostages. Each chapter provides an exciting story from his tenure with the FBI, along with the techniques he used to help direct the negotiation in his favor. He then goes into additional examples of how he has used these techniques when buying a new car, negotiating salary increases, and even how to get an unresponsive individual to respond to your emails.

Like any self-help book, it’s easy to read but more difficult to put into practice. I’ve already used many of the strategies Voss teaches in his book, and it is one of the most useful self-help books I’ve ever read.

Never Broken by Jewel

Never Broken: Songs Are Only Half The Story — Jewel

I am not a huge fan of Jewel’s music, nor am I a folk music listener in general. Before reading this book, the only things I knew about Jewel was that she’s an Alaskan singer/songwriter that had a few hits in the late 90s.

After reading the book however, I learned that she is a pretty incredible person: she dealt with abuse from her family, lived out of her car for a while, paid her way through music school, is a yodeler, and has spent a lot of time about thinking about life and philosophy (one of my favorite observations from her was that “hardwoods grow slowly”, referencing how growth needs to be a long-term goal).

Overall, Jewel’s Never Broken has many good lessons and interesting stories from her time growing up as a folk singer. After reading it, I have a much better appreciation for her music too.

Priceless by Robert K. Wittman

Priceless: How I Went Undercover to Rescue the World’s Stolen Treasures — Robert K. Wittman

Another book on my list from a former FBI agent (these FBI guys sure do have interesting stories to tell!).

Robert Wittman specialized in art crime during his FBI tenure, helping track down stolen masterpieces. Lots of art crime is difficult to prosecute because details are difficult to verify — a lot of the time Wittman’s stories come down to Ocean’s Eleven style sting operations with lots of planning, false identities, and large SWAT teams storming into hotel rooms to take down the criminal dealers and save the works of art.

Besides the crime thriller aspect of the stories, the book also provides good introductory background on art and the different types of crimes that get committed, from breaking into and stealing from museums to illegally selling Native American bald eagle feather headdresses, making the book both exciting and informative.

The Hidden Life of Trees by Peter Wohlleben

The Hidden Life Of Trees: What They Feel, How They Communicate — Peter Wohlleben

Peter Wohlleben is a German forester who has spent his life in nature, initially as part of the logging industry but more recently as a custodian of natural growing forests. His book The Hidden Life Of Trees discusses the importance of diversified (yet native) flora and how old-growth natural (not planted by humans) forests have amazing ecosystems.

Wohlleben anthropomorphizes trees to the point that you will feel bad the next time you accidentally snap off a twig, however the book is full of amazing information about how trees “communicate” with each other and how trees share some of the same “senses” that we humans have like the senses of sound and touch.

The Hidden Life of Trees is a light read that will make you appreciative of your surroundings the next time you are taking a hike in the woods.

Full Dark, No Stars by Stephen King

Full Dark, No Stars — Stephen King

I read six Stephen King books this year (still have quite the backlog to get through) and Full Dark was by far my favorite.

This book is a collection of four short stories. I only really liked three of the stories, but even so this is one of my favorite Stephen King books of all time.

Although I generally like all of King’s books, I think this one was especially great because it wasn’t focused on the psychic /other-worldly aspects like in many of his other stories — instead this book focuses on real-seeming characters with their real-seeming problems.

I think the relatability to the characters in this book is what makes the stories especially terrifying.

Thanks for reading. You might also enjoy following me on Twitter.

Want to learn even more SQL?

Sign up for my newsletter to receive weekly SQL tips!