Hi Guys

+1 to using DI, -1 to static initializers for anything other than types
without dependencies, for example, primitives and Strings.

To be fair, the lunatic (me) that originally wrote this stuff did say (in a
post or jira, I can't remember which) that this was a proof of concept which
should be refactored to use injection and was at best alpha. To be honest,
I'm astounded that it has stood up as well as it has.

As to the synchronization issues, the lazy initialization pattern (that
Stefano so loves) is not an accident. The intent is that in deployments
where synchronization is required, you subclass to add synchronization,
normally just on the getter method. In single threaded or per thread
environments, the vanilla code is just fine. I hate synchronization being
imposed when it is not required. Similairly, if you want to avoid lazy
initialisation with this pattern, you just invoke the getter earlier, such
as in the constructor of the using class. Just please not in a static
initialiser which is invoked when the class is loaded, which occurs who
knows when!

I can't claim I applied these rules in the initial drop of jSieve. I never
explored the areas requiring synchronization. Good luck with this :)

Anyway, thanks to all of you for taking this on and cleaning it up.

Unfortunately, I've way too many other commitments to get involved beyond
the occasional (worthless?) post.

Cheers

-- Steve



> -----Original Message-----
> From: Bernd Fondermann [mailto:[EMAIL PROTECTED]
> Sent: 09 August 2007 23:24
> To: James Developers List
> Subject: Re: [JSieve] Sporadic Mysterious Exceptions
>
>
> On 8/9/07, Robert Burrell Donkin
> <[EMAIL PROTECTED]> wrote:
> > On 8/9/07, Stefano Bagnara <[EMAIL PROTECTED]> wrote:
> > > Robert Burrell Donkin ha scritto:
> > > > On 8/9/07, Stefano Bagnara <[EMAIL PROTECTED]> wrote:
> > > > https://issues.apache.org/jira/browse/JSIEVE-10
> suggests removing the
> > > > singletons and injecting the dependency instead. not
> sure how much
> > > > work that is likely to be.
> > > >
> > > > - robert
> > >
> > > As a personal approach I try to avoid static fields
> (singletons, thread
> > > locals and anything else using static fields) at all
> costs, but I know
> > > I'm a bit extreme at this.
> >
> > same here
>
> +1
>
> and not extreme at all. this is considered a code smell broadly. for
> example, it hinders proper unit testing.
>
>   Bernd
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


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

Reply via email to