Get the latest tech news

What makes code hard to read: Visual patterns of complexity (2023)


Not long ago, I was auditing a codebase for work (looking for bugs) when I realized that despite the quality of the code, I was becoming mentally fatigued extremely quickly and had a hard time working on it for long stretches of time…

Halstead’s focus was building a system of related metrics such as program “length”, “volume”, and “difficulty” with a series of equations describing the relationships between them… ambitiously culminating in a numerical value that would estimate the number of bugs contained in the implementation! I once audited a codebase where one module’s author had used three variations of same variable name in a single function, (e.g. node,_node, and thisNode)… unsurprisingly this component was rife with bugs that had security impacts on the larger system Despite the high quality of the code and the authors, we found more than one critical bug, including one that was pretty easy to see… but it had been missed, in my opinion because it was in the middle of a long and complex function that was difficult to reason about.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Code

Code

Photo of complexity

complexity

Photo of visual patterns

visual patterns

Related news:

News photo

Developer convicted for “kill switch” code activated upon his termination | Software developer plans to appeal after admitting to planting malicious code.

News photo

Developer Convicted For 'Kill Switch' Code Activated Upon His Termination

News photo

ChatGPT On macOS Can Now Directly Edit Code