Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
February 28, 2020 11:07 pm GMT

Code readability metrics?

Lets assume you need to build code-readability-meter. How would you do it?

What is code readability?

Readability is the ease with which a reader can understand a written text.

Wikipedia

Readability is what makes some texts easier to read than others.

The Principles of Readability

Many factors play into the readability of text. For example, contrast, font, choice of words and many more. (See: readability for natural languages)

Some factors are subjective e.g. depends on the reader - if the reader knows given programming language, if the reader knows the context if the reader familiar with the jargon, etc. There is a great talk on the subject: Laura Savino - Talk Session: Readable Code. She says that readability needs a reader.

Some factors are objective e.g. doesnt depend on the reader - length of the text, indirection in code, etc.

Subjective factors

In my opinion the only way to control subjective factors of readability is with code reviews e.g. if every team memeber can read and understand give code.

Objective factors

On the other hand objective factors can be measured by the porgramm, for example, we can build graph of function calls or variables, types, clesses dependencies and measure depth of graph.

So the question is: which objective factors we can measure to detect code readability?

Goodharts law

When a measure becomes a target, it ceases to be a good measure

Wikipedia

I want to think about possible metrics of readability to better understand it, I dont plan to make it one of those metrics like, test coverage or so called code quality.


Original Link: https://dev.to/stereobooster/code-readbility-metrics-5393

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To