domingo, 7 de janeiro de 2018

SW Construction: Java Coding Conventions (by Google)

The short story

Here are the Google Java Coding Conventions. made to be easily understood and enforceable (automatically), they are a good insight on what a big company defined as best practices for coding on a certain (widely popular) language:


Quoting:
"Google's coding standards for source code in the Java™ Programming Language. A Java source file is described as being in Google Style if and only if it adheres to the rules herein.
Like other programming style guides, the issues covered span not only aesthetic issues of formatting, but other types of conventions or coding standards as well. However, this document focuses primarily on the hard-and-fast rules that we follow universally, and avoids giving advice that isn't clearly enforceable (whether by human or tool)."

Is your project following any best practices at all? Are they written? Who wrote them? Do you use them at will or is there someone who enforces them? If the answers to those questions are not clear on your mind, read the long story below.

The Long Story

Your company, your department (Domain Expert, CTO, etc.) or even only your PM and TM could define as coding conventions some external document (or standard) to follow during project execution. The advantage could be that you are reusing (documentation) - and thus saving money - as well as saving you - or your team / department - the hassle of keeping it internally updated. 
The other advantage is that, if rightly chosen, nobody will question the authority of such a document (while an output of former teams, projects and/or internal experts) could suffer from that lack of authority and general trustworthiness by everyone involved.

Enforcing the coding standard (coding conventions) into a tool like CheckStyle (that could be inserted as an integration task in the Continuous Integration server) is also a good idea because early deviations will have to be fixed by the team (you could make the build fail if a rule - even a formatting one - is broken). 

Updated: 2018-01-07, short and long story.