What makes code hard or easy to read?
Let’s look at some practices that might lead to poor readability, and then we’ll look at how to get the readability as good as possible.
Why is reading code hard?
Reading code is much harder than writing code for at least three reasons:
- When writing code, you have to keep in mind the variables, algorithms, data, and structure of the feature you’re writing only. When reading code, you must keep in mind all the information about wider functionality and potential functionalities that you’ve guessed from your reading of the code so far.
- Thinking is easier than understanding someone else’s thinking – vastly easier.
- It’s not your code – your baby, so it’s probably not as good as something you could write, or at least that’s the thinking of many programmers. That’s the emotional aspect. Alternatively, you might be thinking that the code is written by someone...