Skip to content

Latest commit

 

History

History
87 lines (49 loc) · 3.49 KB

java.md

File metadata and controls

87 lines (49 loc) · 3.49 KB

Java code has the big advantage of being very portable.

Recommended sources of information

Installing Compilers and Runtimes

Its recommended to use the latest official Oracle version (Java 8) if at all possible. OpenJDK is usually ok as well, but definitely avoid gcj.

Editors and IDEs

For Java we normally use the Eclipse IDE.

Coding style conventions

We follow the standard coding style defined by SUN.

Latest version seems to be available here.

We have standard code formatting settings for eclipse.

TODO: describe tabs-vs-spaces and indentation size.

code-format-nlesc-v2.xml code-cleanup-nlesc.xml

Automated checking of the code style can be done with PMD and FindBugs.`

TODO: add (a link to) our standard ruleset.

Building and packaging code

As a build system we normally use Gradle. This also determines the project layout, and has standard features for packaging code.

Testing

The standard unit testing framework in Java is JUnit. Try to use Junit 4 if at all possible.

Use following naming scheme to distinguish unit and integration tests:

  • Unit tests: */Test.java, **/*Test.java, and **/*TestCase.java
  • Integration tests: */IT.java, **/*IT.java, and **/*ITCase.java

Test coverage can be measured with Jacoco. For running and viewing Jacoco code coverage, use eclemma

Code quality analysis tools and services

Code quality and coverage grouped by file. Can setup goals to improve quality or coverage by file or category. For example project see https://www.codacy.com/app/NLeSC/Xenon/dashboard

SonarQube is an open platform to manage code quality which can show code coverage and count test results over time. Sonar Qube can analyze Java, Python and Javascript.

Can show code coverages for many languages including Java, Python and Javascript. Shows unified coverage and separate coverage for matrix builds. For example project see https://codecov.io/github/NLeSC/Xenon

Debugging and Profiling

Use jConsole or jVisualVM.

Logging

For logging, we use the slf4j api. The advantage of slf4j is that it is trivial to change logging implementations. The API distribution also contains a few simple implementations.

To get logging info into Eclipse, one option is to use logback beagle.

##Writing documentation

Java has the inbuild JavaDoc system for generating API documentation, usually in the form of HTML. Highly recommended.

##Recommended additional packages and libraries

JFreeChart is a Java library that allows to do nice looking charts.

Available Templates

There are currently no Java templates available. See The Xenon repo on GitHub as an (rather complex) example.