Code style - GeoscienceAustralia/earthsci GitHub Wiki

The EarthSci project has adopted a consistent coding style, which is applied across the project.

This is common best-practice in the software development community, and is done for a number of reasons:

  • To make it easier for developers to understand and work on code they themselves have not written
  • To minimise noise in merge diffs caused by mis-matched formatting
  • To give the codebase a consistent feel
  • To adhere to best practices (use of annotations, compiler directives etc.)

Specific style and formatting guidelines are given below. If you encounter a scenario not covered below, try looking for a similar file within the codebase and follow similar style and formatting.

All developers should adhere to this style when contributing to the project, including patches contributed via pull requests etc. If you have strong objections to the style used in the project, and can make a good argument for an alternative (i.e. better than "I like this way better") please feel free to raise a new issue and make your case (we are always willing and happy to improve our craft).

## Java The java coding conventions adopted within the project are based on the [Oracle Java code conventions](http://www.oracle.com/technetwork/java/codeconv-138413.html).

The main features of the style used in the project are:

  • Vertically-aligned braces
  • Indentation within blocks
  • Single statement per line
  • Max line length of 120 characters
  • Double-indenting on wrapped lines
  • Appropriate use of whitespace to increase readability

An Eclipse code formatter that implements the EarthSci code style is available here. This formatter has been embedded into the plugin projects. You can also apply it as a global default by importing it into Eclipse using Window->Preferences->Java->Code Style->Formatter->Import....

We highly recommend using the Eclipse "Save actions" feature to perform formatting and code cleanup on source code on save. To activate this feature, goto Window->Preferences->Java->Editor->Save actions

We recommend using the following settings:

These settings have also been embedded into the plugin projects.

## XML TODO ## Properties TODO
⚠️ **GitHub.com Fallback** ⚠️