That would depend on if the constructor actually *does* something.

If it needs to set up a connection pool, parse an XML configuration file, or
whatever, then you have the choice of,

- doing this once, reliably, in the constructor, or
- making sure that every single last static method checks to see if this has
already been done.

If the singleton needs to acquire, or process a resource in order to
function, then 'construction is resource acquisition' should save a lot of
typing and bug hunting.

Dan.

> -----Original Message-----
> From: Felipe Schnack [mailto:[EMAIL PROTECTED]]
> Sent: 28 January 2003 21:56
> To: Tomcat Users List
> Subject: about singletons (ot)
>
>
>   These days I was thinking
>   It's not so uncommon to have uses for singleton classes in our
> everyday lives. Normally we do that implementing a class that have its
> constructor as private, so no one can instantiate it, and a
> getInstance() method or something like it. We wouldn't have the same
> kind of behavior if we simply declare all class methods/fields as
> static?


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

Reply via email to