Code Style for Orc Implementation Developers#

We use the Scala style from EPFL: http://docs.scala-lang.org/style/

The Scala Eclipse formatting profile and code clean up profile in the OrcScala and sibling Eclipse projects are set up for our style.

Four known problems with this:

  • The formatting profile (Preferences > Java > Code Style > Formatter) needs to be flipped back and forth between "Scala" and "Java standard style". (For example, the indent step is different.)
  • Eclipse's clean up commands occasionally get confused and mangle things.
  • There are a few (approx. 3) places where I reject the standard style because of readability.
  • There are two "Organize Imports" commands: one from Eclipse's JDT, and one from the Scala plug-in its Refactor menu. Neither works correctly on the other language. The Java one is run as part of a clean up, but you'll need to explicitly invoke the Scala one on Scala files.

I run this as follows:

  1. Config formatting profile for Java (Preferences > Java > Code Style > Formatter)
  2. Select all the Java files
  3. Run a clean up (Source > Clean Up)
  4. Config formatting profile for Scala (Preferences > Java > Code Style > Formatter)
  5. Select all the Scala files
  6. Run a clean up (Source > Clean Up)
  7. Run Scala's Refactor > Organize imports

Check the diffs carefully. Look for confused clean ups that break code, and for the few places where the clean up really reduces readability. If you're getting major diffs on existing code, there's something wrong, because the codebase is in quite good shape, currently.

As part of this process, I additionally check:

  1. File header initial comment line ("${filename}.scala -- Scala class ${classname} and ...")
  2. Copyright dates: If the file has been changed, change the copyright year. Do not change the copyright year on untouched files.
  3. Javadoc/Scaladoc sanity (mismatched cut-and-pasted docs, etc.)

Add new attachment

Only authorized users are allowed to upload new attachments.
« This page (revision-1) was last changed on 04-Jan-2017 12:46 by John Thywissen