Programming Style
Style is how you format your code so that it is easy to read and thus easier to understand. Good style includes the use of whitespace, comments, indentation, and naming.
Programming Style General Thoughts on Making Code Readable
As in all writing, the use of whitespace, separators, and formatting is very important. Remember, you almost never write code just for yourself. Other people are going to read and modify your code.
Try to make it as easy as possible for them. The core of good style is well written comments, the use of whitespace, and proper indentation. Each category is talked about below:
The Art of Commenting
You should write comments in your code to allow the "next" programmer to come along and have to update/maintain your code to be able to easily and quickly grasp the high level goals and/or techniques used in your code. A good comment eliminates the need for the "user" of your code to "read" the code itself. The comment should explain the inputs, outputs, and basic workings (in English) of your code. Comments come in two forms: Block comments and Single line comments. A block comment has a "start" and an "end" marker and everything in between is ignored by the computer. A single line comment has a "start" marker and ends at the end of the…