Readability and Naming Things » Code Simplicity
Many people think that the readability of code has to do with the letters and symbols used. They believe it is the adding, removing, or changing of those symbols that makes code more readable. In some sense, they're right. However, the underlying principle is:
Readability of code depends primarily on how space is occupied by letters and symbols.
What does that mean? Well, it means two things:
Code should have the proper amount of white space around it. Not too much, not too little.
There should be the proper amount of space within a line of code to separate out the different parts. Separate actions should generally be on separate lines. Indentation should be used appropriately to group blocks of code.
With this principle, it's actually the absence of code that makes things readable. This is a general principle of life–for example, if there was no space at all between letters and words in a book, it would be hard to read. On the other hand, it's easy to see the moon against the clear night, because there's a lot of clear black space that isn't the moon. Similarly, when your code has the right amount of space in it, you can tell where and what the code is easily.
Read full article from Readability and Naming Things » Code Simplicity
No comments:
Post a Comment