Wäre eine Zusammenfassung für die Umsetzung

Formatierung

Spring Dependency Injection

Siehe https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#beans-dependencies:

Constructor-based or setter-based DI?

Since you can mix constructor-based and setter-based DI, it is a good rule of thumb to use constructors for mandatory dependencies and setter methods or configuration methods for optional dependencies.

The Spring team generally advocates constructor injection, as it lets you implement application components as immutable objects and ensures that required dependencies are not null.

Setter injection should primarily only be used for optional dependencies that can be assigned reasonable default values within the class. …

public class MyClass {

    @Autowired
    private MyDependency myDependency;
}

Koding

Util Klassen

  • Name endet auf “Utils”, z.B. “MyUtils”
  • Haben einen privaten Konstruktor der Art:
    private MyUtils() {
          throw new AssertionError("No MyUtils instances for you!");
    }
    

    passendes Eclipse Editor Template:

    private ${enclosing_type}() {
        throw new AssertionError("No ${enclosing_type} instances for you!");
    }
    

    (siehe auch Kode von java.util.Objects.Objects())

Tests

Exceptions

Logging

Siehe …