tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Brown" <>
Subject RE: about singletons (ot)
Date Wed, 29 Jan 2003 08:50:20 GMT
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.


> -----Original Message-----
> From: Felipe Schnack []
> 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:
For additional commands, e-mail:

View raw message