> -----Original Message-----
> From: Jon Scott Stevens [mailto:[EMAIL PROTECTED]] 
> 
> on 4/3/02 10:46 AM, "Geir Magnusson Jr." <[EMAIL PROTECTED]> wrote:
> 
> > Right - and with what I am thinking about, be defensive.  
> Don't just 
> > use 'logger' - wrap it with a check.
> >
> > Or have an internal log method that does that....
> 
> So, for every class, I now also need to copy/paste in some log method?
> 
> <sarcastic>
>   Now that is smart OO engineering.
> </sarcastic>

:)  Agree.


> >> I really don't understand why that is better than the Pull model 
> >> which would be more like this:
> >> 
> >> class MyComponent
> >>   implements Component, LogEnabled
> >> {
> >>   private static Logger logger = Log.getLogger();
> >> 
> >>   myMethod() 
> >>   {
> >>       logger.info("Hello World!");
> >>   }
> >> }
> >> 
> >> Seems so much cleaner of a design to me and it is 
> impossible to get 
> >> an NPE.
> > 
> > Except that forces there to be something called Log in the 
> classpath.  
> > In the case where you are using the component/tool in an 
> environment 
> > where that doesn't exist, you'll get a different exception, out of 
> > your control...
> 
> Isn't the point of the Commons project to come up with a set 
> of re-usable components? Isn't the point of the 
> Commons-Logging project to come up with a small .jar file 
> that you can just drop into your classpath and use with 
> whatever logging system you want?
> 
> Seems that we are trying to avoid the point of why we write 
> software for Jakarta.


It also seems that you guys are forgetting Container/Component
relationships.
Avalon uses Factory classes to ensure the proper lifecycle of a
component.
Excalibur's component package and the new container package (soon to be
renamed)
are examples of that approach.

You only need to be defensive if you don't trust your container.  Is it
possible to get an NPE?  Sure it is, but the likelihood of it happening
if
the component is instantiated by a proper factory class is nill.  It's
when
you start mucking around with creating your own containers and such that
you have to be careful...  That's why we use classes to encapsulate the
complex lifecycle stuff on our components.  There is less room for
mistakes.

BTW, we will be altering the Avalon AbstractLogEnabled to throw an
exception
if no logger has been set before it is called.


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to