DEV Community

Bill Schneider
Bill Schneider

Posted on

6 1

Readability analogy in music

This article originally appeared on my blog

In music, you can often write the same note two different ways, for example, B-flat and A-sharp correspond to the same key on a piano keyboard. When you use which depends on surrounding context. A chord C/E/G/B-flat is a C dominant 7th and resolves to an F chord. The same chord written
as C/E/G/A-sharp is an augmented 6th and resolves to B major. So which way the chord is written tells you something about where it's going next.

The other day, I saw music with an augmented 6th chord written as a dominant 7th, and I found it confusing to look at a sequence of notes
like A-natural, A-flat, A-natural. Given the first two notes in that sequence, you usually expect the third note to be G.

So what does this have to do with code?

Readability matters.

With code, you can often get the same end result multiple ways. It's important for your code to look like what it does, so anyone reading it
will be able to understand it. Since we spend at least 90% of our time reading code (the Uncle Bob figure) focusing on readability will improve
productivity.

Poorly named methods are the equivalent of that A-flat that should have been written as a G-sharp: it will sound (or work)
the same, but you're making the reader work harder than they should have to.

Image of Datadog

How to Diagram Your Cloud Architecture

Cloud architecture diagrams provide critical visibility into the resources in your environment and how they’re connected. In our latest eBook, AWS Solution Architects Jason Mimick and James Wenzel walk through best practices on how to build effective and professional diagrams.

Download the Free eBook

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more