Slider Code Style Rules

The [Apache Hadoop Guidelines|https://wiki.apache.org/hadoop/CodeReviewChecklist] apply to the slider code with some minor changes

All

  • Lines can be up to 100 characters long.

Java

  • SLF4J is the logging platform. Log operations do not need to be guarded with f (log.isDebugEnabled()) statements; instead the log string should reference variables inline with {} references, rather than append strings to build the log statements.

  • Provide meaningful toString() operations for debugging, logging and assertions.

Groovy

Groovy is used for most of our test cases. It's style guidelines are similar to those of the Java guidelines

  • use groovy in-string variable expansion in log messages
  • mark classes as @CompileStatic (sometimes this breaks the compilation, comment out if so)
  • use groovy asserts over JUnit asserts —the diagnostics are better.
  • You can use == in assertions; Groovy maps it to Object.equals(). the operator is is used for equality tests.
  • to break up bits of a test run, use the {{describe()}} method to print out the next action. This helps understand what is happening in a (noisy) output stream.
  • avoid esoteric Groovy that isn't immediately obvious to developers with minimal Groovy experience.

Obscure bits of Groovy to avoid the rules of how strings are evaluated to true or false in conditions, or the more [esoteric operators|http://groovy.codehaus.org/Operators] such as 'spaceship' or 'elvis' automatic return values of functions (except for very short ones) * applying actions across entire list elements. (if used: comment)

Python

  • Python files must use an indentation of four characters.

Maven POM files

  • Versions of artifacts (and template dependency definitions) MUST go into the root slider/pom.xml; individual modules MUST then repeat the dependency declaration, excluding version and exclusion details. This is to keep versions consistent across the project.