Clean Code : Keep code clean :: Formatting
Formatting |
- First of all, let’s be clear. Code formatting is important.
- It is too important to ignore and it is too important to treat religiously.
- Code formatting is about communication, and communication is the professional developer’s first order of business.
- We want their eyebrows to rise as they scroll through the modules.
- We want them to perceive that professionals have been at work.
Think of a well-written newspaper article. You read it vertically. At the top you expect a headline that will tell you what the story is about and allows you to decide whether it is something you want to read.
Nearly all code is read left to right and top to bottom. Each line represents an expression or a clause, and each group of lines represents a complete thought. Those thoughts should be separated from each other with blank lines.
There are blank lines that separate the package declaration, the import(s), and each of the functions. This extremely simple rule has a profound effect on the visual layout of the code.
Recent Comments