steve icon indicating copy to clipboard operation
steve copied to clipboard

Prefer constructor injection

Open juherr opened this issue 2 years ago • 4 comments

First baby step for #1202

juherr avatar Aug 29 '23 15:08 juherr

Ping @goekay

juherr avatar Sep 11 '23 12:09 juherr

Ping @goekay

juherr avatar Jul 14 '24 13:07 juherr

Ping @goekay Should I close or update this PR?

juherr avatar Aug 10 '24 12:08 juherr

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. Furthermore, constructor-injected components are always returned to the client (calling) code in a fully initialized state. As a side note, a large number of constructor arguments is a bad code smell, implying that the class likely has too many responsibilities and should be refactored to better address proper separation of concerns.

(https://docs.spring.io/spring-framework/reference/core/beans/dependencies/factory-collaborators.html)

juherr avatar Aug 10 '24 12:08 juherr

Closed because the issue is outdated

juherr avatar Jul 27 '25 21:07 juherr