CS 246 - Code Conventions and Style
Overview
An important component of software development, especially when working with others, is learning to use a consistent programming style. This is especially important when multiple developers are contributing to the same codebase.
Using a consistent style in a project provides the following benefits:
It will help developers to navigate through the code more quickly.
It helps you to spot errors.
It reduces the cost of code maintenance
Style Guides
Most languages have a generally accepted style guide for that language. In addition, many companies have their own software style guides. Learning to follow a style guide is an important skill.
In this course, we will use one of the most popular style guides for Java programming, the Google Java Style guide.
This style is likely different than what you're used to using when programming in C++. For example, it uses the “K & R style” of braces (Style Rule 4.1.2), where the opening brace appears on the same line as the method name or if statement:
if (expression) {
statement;
statement;
}
Please take some time to become familiar with the style guide, especially the formatting requirements from section 4.