Blogger

Delete comment from: Javarevisited

Jonathan Brist said...

One of the principle which I follow to choose between Setter Injection vs Constructor Injection is principle of mandatory and optional, yeah It's What I call it :). If any dependency is mandatory for an Object to perform its duty then you should use Constructor Injection, having said that optional dependency can be injected using Setter injection. This technique gets best from both Setter and Constructor injection and its also good from maintenance point of view as it clearly high light which dependency is critical for object to work.

Dec 18, 2012, 1:00:52 AM


Posted to Difference between Setter vs Constructor Injection in Spring

Google apps
Main menu