Skip to content

Coding style

felixreimann edited this page Jun 12, 2018 · 3 revisions

Formatting options

  • For Eclipse, use the formatting options in info/eclipse_formatter.xml. You can import them with Window->Preferences->Java->Code Style->Formatter->Import ... [eclipse_formatter.xml]
  • We recommend to automate this with Window->Preferences->Java->Editor->Save Actions
    • Format all lines
    • Organize Import
    • Additional actions
      • Convert control statement bodies to block
      • Remove unused imports

Tests

We would like to have a good test coverage (still working on it). Thus, we want to have both:

Unit tests

We want to have at least one unit test per method. Thus, most methods are either protected or public. A unit test tests a single method on its own, i.e., it tests if the output fits to a given input. The input should be as simple as possible.

  • in the folder src/test/java
  • using junit
  • target code coverage > 97% exept for GUI and example code

Integration tests

Integration tests test a whole combination of classes and their correct interaction.

  • in the folder src/integration-test/java
  • using junit

Method visibility

  • methods are public if they should be used from another object (API)
  • methods are private if the handle an internal state of the object which must not be corrupted
  • all other methods are protected that the class could be extended

Javadoc

Read How to Write Doc Comments.

Clone this wiki locally