We try to follow the Sun Code Conventions.

Here are some highlights about what this means:

    log.trace("Entering storeRecord with record '"
              + rec.getId() + "'");
    /* doesValidate causes an external call to a
       XML-validator, so it is fairly slow. */
    if (doesValidate(rec)) {
        storage.store(rec);
        log.info("Stored validated record '"
                  + rec.getId() + "' to store '"
                  + store.getId() + "'");
    } else { // We have no alternative here so pass it on
        throw new StorageException("Could not store "
                                   + " record '"
                                   + rec.getId()
                                   + "' as it is invalid");
    }

If in doubt, refer to the documentation.

Furthermore the following should be observed:

// TODO:

// FIXME:

to get FIXME to work in Idea, go to Settings | IDE Settings | TODO and add the pattern \bfixme\b.* to the list.

If IDEA warns about e.g. duplicate strings and it makes sense to have these duplicate strings, insert a suppress warning annotation or comment. This indicates a conscious choice and removes the warning. The square should be green, super green.

You can download a configuration file for IntelliJ, containing the proper codestyle settings and code templates here: IJCodeStyleSettings.jar

To use the configuration in your IDEA, go to the "File" menu, choose "Import settings" and select the JAR file just downloaded from this page. This will make IntelliJ enforce the above rules in most cases, however, please notice that it sometimes fail to correctly wrap lines (e.g. javadoc lines containing HTML tags) and that it has an annoying habit "fixing" (i.e. corrupting) properly formatted lines.

CodeStyle (last edited 2010-03-17 13:09:35 by localhost)