<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Tue, Sep 13, 2016 at 6:29 AM Etienne Dysli-Metref <<a href="mailto:etienne.dysli-metref@switch.ch">etienne.dysli-metref@switch.ch</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">> Since you can mix constructor-based and setter-based DI, it is a good<br>
> rule of thumb to use constructors for mandatory dependencies and<br>
> setter methods or configuration methods for optional dependencies.<br></blockquote><div><br></div><div>For what it's worth, I try to follow this convention in the code I write. (I recall Brent said as much also.) I think it makes the requisite and optional component dependencies crystal clear, though with the tradeoff in Spring wiring as we've noted. I'm hopeful that there is some metadata we can add to constructor arguments (i.e. annotations) that would preserve the symbolic names used in the wiring to prevent the "arg renames break wiring" problem:</div><div><br></div><div><a href="http://docs.oracle.com/javase/6/docs/api/java/beans/ConstructorProperties.html">http://docs.oracle.com/javase/6/docs/api/java/beans/ConstructorProperties.html</a><br></div><div><br></div><div>M</div><div><br></div></div></div>