At 05:26 AM 6/21/2002 -0400, you wrote: > > > ComponentException is a > > > system exception not an application system and should be handled by the > > > container not by individual component. Receiving a ComponentException > > > should mean that the whole component is fubared. > > > > I simply disagree on the concept, but it doesn't matter as long as there > > is a way to ask to the container if a component is present in the system > > without having to catch an exception. > >I'm a non-committer and a total Avalon newbie, but I just can't resist. >In the olden days (read: C programming), it would be OBVIOUS that you >would do > > Component c = container.lookup(name); > if (c == null) > // not found > else > // found > >I know having the exists() method achieves the same, but any sane >programmer would retch at the idea of doing TWO searches, one to >ensure the component is there, one to retrieve it.
Well the "search" should be just a lookup in a table using a simple hashing algo. So exists() should be relatively cost free. lookup() may be expensive (due to instantiation costs or whatever) or it could be also lightweight. > There, I said it. Perhaps this doesn't apply in the Avalon world, but >I fail to see why lookup() couldn't just simply return the component >when it is found, or null in any other case. Unfortunately that style of development tends to hide bugs. The reasoning for it is the same reasoning why java moved from using return codes to indicate errors to using exceptions to indicate errors. It is expected that you should never use lookup() unless you know the component is present. Mostly style for safety ... I started out hating but then learnt to live with it and now I think it is all good ;) Cheers, Peter Donald ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Faced with the choice between changing one's mind, and proving that there is no need to do so - almost everyone gets busy on the proof." - John Kenneth Galbraith ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>