Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Wherever possible common functionality should be placed into an abstract or utility class, as applicable. A good example of this is the AbstractUsernamePasswordAuthenticationHandler, which most classes that use UsernamePasswordCredentials should extend from.

CAS3 Specific Code Conventions

Brackets

All brackets should appear in compact form and are mandatory even for single line statements.

Code Block
java
java

public class FooClass {
    public void BarMethod() {
        if (...) {
            // single line statement
        }
    }
}

Needless else clauses

We do not use needless else clauses. We would write:

Code Block
java
java

public class FooClass {
    public String BarMethod() {
        if (...) {
            return "foo";
        }
        
        return bar;

    }
}

rather than

Code Block
java
java

public class FooClass {
    public String BarMethod() {
        if (...) {
            return "foo";
        } else {
            return "foobar";
        }
    }
}

Indentations

Code indentation should be set to use 4 spaces. Tabs should never be used for indentation.

Simple Logging Facade

We use Simple Logging Facade. In the case where we are extending an abstract class someone else provided for us, and if they were so kind as to provide a protected Logger instance for the runtime class, we'll try to use that. In the case where we create our own Log instance, we will name it "logger".

Qualifying instance variables with "this"

We qualify all instance variables with "this" with the exception of the SLF4J (named "log" or "logger"). We don't qualify that variable with "this" because it is well-known to be threadsafe. log.warn("Message") becomes more idiom than invocation of instance variable.

Use of the final keyword.

We use the keyword "final" wherever we can, because it is probably a good idea.