The importance of programming style
Just like with the English language, programming has syntax and style. Each programming language has basic syntax that is unique to each language, and must be used correctly to get an application to run. The same applies to a spoken or written language. To indicate that you're talking about a dog, you must use the proper word for a dog. In English, questions must be followed by a question mark, and yelling is typically followed with an exclamation mark! Without these, the intent of the statement is not usually received, and the meaning can be lost.
Outside of proper syntax for a language (programming, spoken, or written), the use of consistent style allows the reader to easily follow the flow of the code or writing. Styles aren't necessarily required, but highly recommended if anyone but yourself will be using the code (and still recommended otherwise, since you might not be able to read your own code in the future).
While researching, I found that Google has its own style guide for C++ and Java. Microsoft has its own conventions for C#. I would expect to see that the Google C++ and Java style guides share a lot in common. As I read more into them, I found that the Google styles are less of a recommendation and more of a strict guideline, which constricts what tools the programmer can use in the code. The guidelines are apparently used to make the code more readable, and easier to fix should any bugs arise. This seems to be more of a company standard, rather than a suggestion. On the other hand, the C# programming style offers tips and recommendations on how to format the code, to make it easier to read.
One thing I found that all three share in common is what casing style identifiers should use. All three recommend starting the first word of an identifier with a lower case, with the rest of the words starting in upper case (known as camel casing). Each style recommends starting Boolean variables with a linking verb, such as "should," "can," and "is" (I spent too much time finding out that these are called linking verbs!). All three also recommend starting functions and methods with verbs, such as "get," "compute," and "divide." Outside of readability, each style seems to recommend certain practices to make the application more efficient.
I found that all three style guides had one main goal - consistency. When the indentions, naming conventions, and layout throughout the code is uniform, the code is easier to read, easier to maintain, and easier to update.
Comments
Post a Comment