Search code examples
javareadabilitycode-readability

Static and public positionning


I am working with Apache log4j (http://logging.apache.org/log4j/2.x/) and I realized that in their implementation they always declared their function like this:

  static
  public
  Logger getLogger(Class clazz) {
    return LogManager.getLogger(clazz.getName());
  }

instead of

  static public Logger getLogger(Class clazz) {
    return LogManager.getLogger(clazz.getName());
  }

Is there any good reason for using this style?


Solution

  • On the FAQ it says:

    Log4j has adopted a rather conservative approach by following the Code Conventions for the JavaTM Programming Language

    However, if you check the examples in the Java Coding Conventions, you find that all the modifiers go on a single line before the function:

    public void doSomethingElse(Object someParam);
    

    If I'd have to guess, I'd say it makes the diff easier to spot when committing patches and also maybe avoids long lines.