Formatting

Source code format includes such aspects as indentation, line length and whitespace. The formatting of source code is o­ne the core components of any style guideline or coding standard. The reason for this is that these aspects play a critical role in the readability of source code.

For instance, a programmer must read ten pages of source code and each page employs a different indentation level. As that programmer moves o­n to each new page, his or her eyes must adjust to the new level, in effect wasting time. This may seem like a small price in the context of ten pages. However, consider that programmers work over the course of a day, a month, a year.

In terms of computer programming, indentation refers to indent style as well as indentation level. Indent style refers to how entire blocks of code are indented. The C programming language and the many derivative languages made the common indent style popular due to the use of the curly brackets to outline the blocks.

In the days of yore, computer terminals had very limited widths, often measured in terms of columns. Today’s premier software editing suites still allow us to consider our code in terms of columns. It was due to these column limitations that coding standards dictated minimum and maximum line lengths. Modern coding standards have downplayed the importance of line length due to the size and versatility of modern displays.

Whitespace is a critical component of style because of cross-compatibility. For instance, if a coder indents a code block using five SPACE characters, he or she can be confident that this code will look the same to a programmer working o­n a Linux or Mac platform. o­n the other hand, TAB characters are not treated the same in Windows as they are o­n Linux as they are o­n Mac. If a programmer indents via a TAB character, they can have no confidence that the code will display the same for another o­n a different platform.