RE: Exceptions (was: RE: [Avalon4:PROPOSAL] Context Consensus)
"Berin Loritsch" <[email protected]>
| Newsgroups | gmane.comp.jakarta.avalon.apps.devel,gmane.comp.jakarta.avalon.devel |
|---|---|
| Message-ID | <[email protected]> |
> From: Stephen McConnell [mailto:[email protected]] > > In such a scenario, I would put in place a test case that did the > casting - and avoid object activation whenever possible. For > example, I > will typically use the methof hasService( key ) on the > ServiceManger to > validate that the key is available - but I will pass on the service > manager to subsidiary components without actually getting the > value of > the key - that because in the assembly API service don't get > activated > until they are actually needed - that makes lookup an expensive > operation on the first hit operation. What would be better in that > scenario would be a hasService( key, class ) method where class is > parameter that is the target cast class and the implementation of the > service manger can validate if the candidate object > implements the class > without necessarily instantiating it. > > The same logic applies to a new or revised context interface. It is still a fragile contract.