We employ a set of project guidelines that developers are expected to adhere to. They are meant to keep our project manageable as opposed to slowly spiraling into chaos and certain oblivion. If you're following the Getting Started guide, you've already encountered some of the guidelines, disguised as settings on the Configuring Eclipse page. They won't be mentioned here again.

The project guidelines can be divided into two broad categories: management guidelines, and coding guidelines.

Content

Management Guidelines

We know the term sounds business-y, but just bear with us for a minute. These are our guidelines:

Coding Guidelines

The coding guidelines are guidelines that we cannot enforce solely with the Eclipse configuration:

Exception Handling

Default handling:

IStatus status = new Status(IStatus.ERROR, MyPlugin.PLUGIN_ID, message, exception);
StatusManager.getManager().handle(status);

If you want to force the status manager to display the error in a dialog, pass the option StatusManager.SHOW.

How to Throw an Exception

The throwable classes are Error, Exception, and RuntimeException. You should choose to throw either an Exception or a RuntimeException. In the first case you must specify the exception in the method's throws declaration (checked exception), in the latter case this is not required (unchecked exception). In most cases it is advisable to throw a more specific subclass in order to give a hint on what has happened.

Another hint: often some cleanup code is required that needs to be executed in case of an exception as well as in the normal case. Use a finally block to do this! You can also make a try ... finally block without any catch block, which is very useful.

Checked or Unchecked?

Checked exceptions have the advantage that it is explicitly visible that such an exception can occur and must be handled in some way. They should be used when specific problems are likely to occur and it is known in advance what kind of problems must be covered. A good example is IOException.

Unchecked exceptions have the advantage that it is not required to attach throws declarations for any type of exception that can occur in any part of the call tree. They should be used when it is not known in advance what kind of problems can occur or the problems may occur only in a very deep part of the call tree. This applies to programming errors, which may invoke unchecked exceptions such as NullPointerException or IndexOutOfBoundsException and should always be made visible to the user. Often it is also useful to wrap exceptions into unchecked exceptions:

try {
    // ...
} catch (IOException e) {
    throw new WrappedException("Oh no, the input file wasn't found!", e);
}

Platform Independence

Always try to separate user interface code from conceptual or algorithmic code. This avoids dependencies on GUI stuff in pure algorithm projects, such as KLay. A big concern is to avoid Eclipse dependencies in KIELER's base plug-ins to make the code as portable as possible. Other people might want to use it, but might not be developing Eclipse-based projects.

That being said, Eclipse is still the main platform for KIELER, and many projects are tightly integrated with it.

Special KIELER Issues

In order to stay platform-independent, KIELER handles preferences and algorithm progress monitoring independently of Eclipse. Thus, don't use the standard mechanisms, but the KIELER ones: