“What are coding conventions?“
Coding conventions are a set of programming language guidelines that are specific in their practice for every aspect of a given program. These conventions are established to create consistency.
“What is the benefit of everyone in a team adhering to a convention like this?”
Adhering to a set of coding standards allows for ease of readability, especially important when working in a team environment. It allows for extra time taken to explain written code as unnecessary, which can hinder productivity.
“Is there any benefit to sticking to a convention even when you’re working alone?”
Although you may not be working in a team, individual coding should typically follow a set of popular conventions. These conventions could be simple, such as commenting out classes and methods or in regards to naming schemes. However, if another individual looks at this code, having easily readable code makes a program easier to understand. Coding can be related to English in this aspect; writing a paper typically follows a set format, and having that common understanding allows for expectations to be set prior to reading an essay. When you read someone’s code, one may expect written comments and explanatory names for classes, methods, and variables that help explain the program’s function.
“Is there any downside to coding conventions?”
Coding conventions are great in that they produce consistency, but reduce the ability for anyone to stray away from said conventions. Generally these standards are defined by a set group to be followed by many, with their definition of what “good” code looks like being the definitive. They must also adapt and be updated over time.
The following questions refer to Google’s Style Guide for Java
“What are the areas addressed in the Google guide that you are most surprised are specific?”
I found spacing and indentation to be a rather surprising about how specific it is. While I expected for formatting to be especially detailed, the lack of indentation characters. Line breaks after opening and closing braces along with +# block indentation originate from K & R Style.
“In what areas does your code not meet these standards?”
I often indent my code rather than following the specific spacing requirements of Google’s standards. I also fail to follow their precise naming conventions and often define local variables at the top of classes rather than close to where they will be used. My variables could additionally be more specific.
“How would you feel about being forced to use this style for the programs you write?“
I wouldn’t mind having to use these conventions, but given that I have learned Java under a certain set of conventions as it is, it would be difficult to entirely shift that knowledge. With time I would learn to adapt, but not tabbing out code would be a difficult habit to break from.