Alexander Zhukov wrote:
You might ask: "what do you mean, man?" :)
Example:
BAD: class MyComponent ... { init() { context = InitialContext(); Service s = context.lookup(...); }
run() { s.doSomething(); } }
GOOD: (acceptable but not an excelent design solution) class MyComponent { public MyComponent(Context ctx, ...) { Service s = ctx.lookup() }
run() { s.doSomething(); } }
You example is best-case scenario
CSI is not a good name though :) because Service in your example is just a dependency, which means CDI name still applies
And if I understand correctly, CSI (Constructor Service Injection ;-) would be
class MyComponent { Service service;
public MyComponent(Service service) { this.service = service; }
run() { service.doSomething(); } }
I think the latter approach is cleanest from an OO-modeling pointof view, but what matters most is that the approach is consistent throughout an application or library.
Cheers,
Hes.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]