Published on 30 June 2013.
Today’s thought is about formatting code.
We have coding standards that dictate how we should format our code. When we make changes to code, we try to adhere to the standard and also make our changes blend together with the rest of the code.
What is the point?
The point is that if all code in a project looks the same, it is easier to parse for a human, and therefore easier to understand. Part of a standard might dictate how we organize code and how we name things, but the other part just says how we should format our text. It might for example say something about where to put braces and how many newlines there should be between blocks of code. The latter part of the standard is only necessary if code is represented as text.
By formatting our text well the structure becomes easier for a human to parse. But why should we need to do this? Why can’t the computer parse the text, show it to us in some nice representation, and let us edit that. Imagine what programming would be like if we didn’t need to bother with, for the computer, irrelevant changes to text and could instead focus more on the structure of our program.
–
What is Rickard working on and thinking about right now?
Every month I write a newsletter about just that. You will get updates about my current projects and thoughts about programming, and also get a chance to hit reply and interact with me. Subscribe to it below.