From: Eivind Eklund Date: 2004-10-12T01:13:46+09:00 Subject: Re: DI service change notifications (Needle ne Syringe) On Tue, 12 Oct 2004 00:48:05 +0900, Jamis Buck wrote: > Eivind Eklund wrote: [ ... code deleted ... ] > My head hurts. :) Sorry about that. > > It builds a dependency tree only inside the present registry. > > Fascinating approach, Eivind. Let me see if I read this right. > > * Registering the callback is nothing special -- just storing the > callback in the hash. > > * When a service is requesed, you register the requested service as a > dependency of whatever service is currently being constructed. Exactly. And only inside the present registry. > > It only count the directly called methods from call/yield, but that > > should be OK for most cases. > > Indeed. However, if this kind of functionality were to be put into the > core of the framework, I would personally prefer to see it robust enough > to either capture all dependencies, regardless of where or how they are > created, or none of them. Given Syringe's current implementation, I > don't think an efficient, general-purpose solution meeting that > criterion can be devised. I'd love to be proven wrong, though. :) I don't think any can be devised, period. And thus, I think that the design criterion is inappropriate - if a problem is too hard, find a smaller and better problem to solve :-) In this case, I think that being able to register the dependency tree for the cases where somebody declares all of their construction "in the same place" might be useful. I also guess this covers at least 95% of the relevant cases, and that the cases where the holes are made will be obvious - and that they won't be obvious if we try to engineer a "complete" solution. And it is easy to create something that lets us add an extra manual dependency for those cases. Having to manually track the dependency trees separately from the instation heavily violates the Don't Repeat Yourself principle, so if there is any chance of this being used for complex cases, I think that a capability to auto-record is important. Then again, I've not used any of this in practice, so I may be totally off the chart. Eivind.