Coding Guideline

Here you find general guidelines for contributing code to the Gentics Portlet Suite


Checkstyle

Checkstyle is a development tool to help programmers write Java code that adheres to a coding standard. It automates the process of checking Java code to spare humans of this boring (but important) task. This makes it ideal for projects that want to enforce a coding standard.

In order to guarantee a high code quality and readability in this product we use checkstyle in our code and we try hardly to avoid code warnings. Please install the Checkstyle Eclipe Plugin like described here (to avoid code style warnings) and keep track of the checkstyle output in the reports on this site.

Java file header

To keep track about the different files and Java classes please add file headers to every new generated file in the following style:

/**
* Copyright: 2013 - Gentics Software GmbH
*
* @author ${user}
* @date ${date}
*/

Javadoc comments to fields and methods

Of course we need good and well written inline Javadoc documentation in our code. Please add Javadocs to every field and method.

Moreover the main goal of that kind of documentation is to directly get a good impression of what that field/method is used for, what it does and how it can be used. Especially for class Javadocs a detailed text is needed. Dont forget: you can use html tags and links.

Example:

/**
 * A factory for creating and accessing exact one instance of PermissionChecker.
 * 
 * <p>
 * For use in any kind of portlets that run in a portal environment. Usage:
 * <p>
 * <code>PermissionCheckerFactory.get().isLoggedIn(request)</code>
 * <p>
 * For configuration create a property file:
 * <code>permissionchecker.properties</code> with following properties:
 * <code>
 * permissioncheckerclass=com.gentics.portal.security.DefaultPermissionChecker<br/>
 * cmseditgroups=1,2,4,5<br/>
 * cmsviewgroups=1,2,4,5<br/>
 * cmsanongroup=3
 * </code>
 */
public class PermissionCheckerFactory {
...
}

With this guideline we are able to provide a high quality, readable, reusable code base