Question

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?

Était-ce utile?

La 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.

Autres conseils

Different people different coding style... In most cases it is choice of individual to select a way to write the code.

I will personally write signature in one line so that it is more understandable to readable to everyone, and mostly least confusing to others reading my code. :)

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top