Code Readability using Indentation and Empty Lines

Learn how to make the code readable by indenting and using empty lines.

Code readability

Let’s go on to discuss why the readability of code is important and how we can use indentation and blank lines to improve it.

Ever since we moved away from machine code, the motivation has been that we want code that’s easier to read and write for humans. We’ll keep this in mind when we’re writing code because code doesn’t just consist of instructions to the computer, but also something that needs to be maintained by either us or others.

As we’ve learned, one tool that we can use to make the intentions of the code clearer to whoever reads it is indentation.

The indentation technique

Indentation is a technique that we use to show that certain code lines belong together in a block. This is typically done for compound statements. Because a compound statement can be constructed of other statements or other compound statements, indentation becomes essential to be able to see which code block a statement belongs to.

Get hands-on with 1200+ tech skills courses.