1.

Which Di Would You Suggest Constructor-based Or Setter-based Di?

Answer»

Since you can MIX both, Constructor- and Setter-based DI, it is a GOOD rule of thumb to use constructor arguments for mandatory DEPENDENCIES and setters for optional dependencies. Note that the use of a @Required annotation on a setter can be used to MAKE setters required dependencies.

Since you can mix both, Constructor- and Setter-based DI, it is a good rule of thumb to use constructor arguments for mandatory dependencies and setters for optional dependencies. Note that the use of a @Required annotation on a setter can be used to make setters required dependencies.



Discussion

No Comment Found