Original article: https://seeinglogic.com/posts/visual-readability-patterns/
This article discusses various visual patterns that contribute to code complexity and make it difficult to read. It examines metrics like Halstead Complexity and Cognitive Complexity, highlighting their strengths and weaknesses in measuring readability. The author concludes that while no single metric is perfect, they provide a framework for understanding and discussing code quality. The main takeaway is that writing readable code involves using simple, familiar patterns, creating smaller functions, and managing variables effectively.
Here are the main rules for making code easy to read, with examples:
1. Line/Operator/Operand Count Make smaller functions with fewer variables and operators.
- Hard to Read (More operators and operands):