Dependency Injection: Should dependent objects be passed as args constructors or not?

In the video here http://code.google.com/p/google-guice/

This explains what it should be.

And here OscarRyz says the opposite. How to explain dependency injection to a 5-year-old?

So now I'm confused.

+3
source share
2 answers

I personally prefer to use the fact that designers can, of course, define all required fields, and those fields that cannot be changed after installation. You can do the same with setters, but there is no direct language support for this.

, - .

+7

Source: https://habr.com/ru/post/1785712/


All Articles