Wednesday, September 19, 2018

Readability is a Tricky One

Readability is subjective, rather than objective. What's readable to you may not be readable to me. In kind, what's readable to me might be gibberish to you.

In fact, I've even seem someone transition from believing that object-oriented designs are unreadable while procedural code is readable to the exact opposite opinion. At the end of a few years training and study, he considered object-oriented designs to be easier to understand and procedural designs to be inscrutable.

This included his own designs from when he believed procedural code was the better way to go.

The audience doing the reading is an important factor in estimating the readability of any given chunk of code. For instance, imagine some code written in JavaScript.

On the extreme ends of the spectrum: It's probably readable to me because my experience makes it so I can read most code, regardless of language. It's probably un-readable to either of my children at the time of this writing because they can't even read natural languages, yet, let alone computer languages.

Closer to the middle: It's also un-readable to someone who is very early in their career and only knows one programming language which is not JavaScript. Yet someone with the same amount of experience but who happens to have chosen JavaScript as their first language might consider the code readable.

Even more fine-grained: That same nascent developer might also not consider a block of JavaScript to be readable. This depends on many factors: What kind of design techniques were used and does he know them? How expressive is the code? Does it use any of the latest-greatest libraries that the developer knows? Does it use any fancy new libraries which are yet-unknown to the developer in question.

Readability is tricky because there are more variables involved in its determination: the knowledge and skill of the reader play a role as well as the code.

Tread carefully.