Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefer constructor injection #1226

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

juherr
Copy link
Contributor

@juherr juherr commented Aug 29, 2023

First baby step for #1202

@juherr
Copy link
Contributor Author

juherr commented Sep 11, 2023

Ping @goekay

@juherr juherr force-pushed the feature/constructor-injection branch from 0652b33 to a4dbd53 Compare July 14, 2024 13:23
@juherr
Copy link
Contributor Author

juherr commented Jul 14, 2024

Ping @goekay

@juherr
Copy link
Contributor Author

juherr commented Aug 10, 2024

Ping @goekay Should I close or update this PR?

@juherr
Copy link
Contributor Author

juherr commented Aug 10, 2024

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants