Noel J. Bergman wrote:
Stephen,I'm not disagreeing.
Yes, containers should be robust. But imagine that a component is passed a
context that is not of the correct type, and it doesn't cast it in
contextualize. It puts it away to use later. As it turns out, that
component rarely uses context. It only needs the context to perform a
particular operation, which it will perform upon request for some other,
possibly third-party, component. So this application is running fat, dumb
and happy for some indefinite period of time until out of nowhere a
ClassCastException ripples out of a component.
Probably not the best situation. Hence my suggestion to at least check the
cast early.
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 scanario 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 implememts the class without necessarily instantiating it.
The same logic applies to a new or revised context interface.
Cheers, Steve.
--
Stephen J. McConnell
OSM SARL
digital products for a global economy
mailto:[EMAIL PROTECTED]
http://www.osm.net
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
