Software Engineering

Why Coding Style is of Vital Importance

follow_rules
I will follow the Coding Rules… I swear!

After many years in the Industry, working on several kinds of Project, I would like to share with my colleagues these thoughts…
In 7 straight points, I would like to promote Coding Styles. Why? Please, continue reading and in a few minutes you will get a clue.

Your code does not belong to you. Coding is like an exercise: having a problem set, finding the solution, coding the solution. Like a Math exercise, a process is systematically applied, so the resulting code is simply a sort of Compilers-readable representation of the merely found solution.

Someone will be maintaining and extending it long after you are gone. Even if the Engineer coding that fundamental piece of the overall system is you, you should think that it will be likely maintained by someone else in the near future, or in the long term. There is the probability that you will be asked to maintain that piece of system months later the first release, and that yourself will get troubles…

Many eyes make all bugs shallow, but if no one can understand your code, no one will look at it. Code Review is a fundamental process, but it may be tiring if the Source Code is not readable: there is no time to ‘decode the source code’, and Engineers normally does not like to waste precious brain cycles. Source Code that is readable and structured is easy to read and follow, so as a result it is easy to mentally debug: several minds debugging a piece of code will be likely able to spot bugs before any expensive software release… are you convinced about that?

There is plenty of room for personal expression even when using someone else’s Coding Style. Coding Style is just a protocol to express and/or implement parts of a solution for a problem set, right? So, whenever you, as an Engineer, find a solution to a problem via a smart Algorithm, coding that Algorithm is already a distinctive sign, it is not needed to introduce into the source code any other personal touch: your touch is the solution, the Coding Style is only a standard way to implement and let the others understand.

Avoid Hungarian notation, leave the compiler’s job to the compiler. You have the role of Engineer, and other Engineers have provided you a tool: the Compiler. What does such Compiler do? As you know, it translates your high level code to a machine readable sequence of byte. Now, what is the reason why you should write source code close to the machine? The compiler will optimize (i.e. your variable names will be shortened, your flow of control will be translated with dedicated CPU flows, etc.), that is for sure… are you comfortable with that?

Read Documentation/CodingStyle. As a professional, you, Engineer, should read the standards to document and code in an enterprise environment: side projects are fun stuff, enterprise projects are as many means to implement business cases and the companies are not willing to waste money in having Engineers decoding someone else’s source code… would you like to decode someone else’s code? Ask to yourself…

Burn it if you want, but follow it. I know that you, Engineer, can argue on that, but, if you will realize that standards for documenting and writing Source Code have to be burnt out, well, this is a good sign: this means you have read them – or at least gone through, and moreover you have matured your own strong opinion. Now, you are free to burn such standards, but due to your strong opinion, as a professional you realize how important is to having a common protocol to describe design choices and to implement them… is this right?
Too many times I have been involved in Code Review processes where I had to argue with some other Engineer about Coding Styles, their importance, etc. The reason why I did that, it is because of the vital importance of such Coding Stylish Golden Rules: writing software is an expensive process, maintenance can be far more expensive if to the normal complications (legacies, design decisions, architectural changes, etc.) ‘ciphered’ Source Code is adding its strong weight.

Everyone – Engineers all in, part of a Leadership Team can recognize the value of having maintainable Code Bases, where for maintainable a multi-facet meaning is given: tested, documented and written according to standards. I would still stress the point: if the Source Code is well written (i.e. it follows the ‘Golden Styling Rules’), half of the overall characteristic is gained: testing is easier and documentation may be superfluous (e.g. variable names should be speaking, no additional lines of documentation should be needed)!

Happy coding according to the Coding Styles…

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s