struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Micael <>
Subject RE: [OT] Use of Static Methods
Date Wed, 09 Jul 2003 21:55:07 GMT
Also, singleton classes are less global too.  Singleton classes can have an 
interface exhibiting their method signatures.  But, you cannot do this, 
obviously, with static methods.

interface Foo {
   static void bar();

class Baz implements Foo {
   public static void bar() {
     // nothing

Won't compile.  This is the whole point and why Singletons generally should 
be preferred.  This also shows why static methods are not "overridden".

At 04:59 PM 7/9/03 -0400, you wrote:
> > > > OO programs should be made up of objects passing
> > > > messages to other objects, not calling global functions.
> > >
> > >I would argue a Singleton is no better in this respect.
> > >
> > >The fact that they're instantiated into an object,
> > >don't make Singletons any less "global" than static
> > >methods.
> >
> > Yes, it does.  You can code a singleton and change the code without
> > changing the interface.  You cannot do that with static
> > methods.  Static
> > must remain static, the singleton can change, depending on
> > how you code it.
>I understand and appreciate the benefits of Singleton
>objects over static methods. Let's rephrase my comment
>to what I should've said in the first place :)
>         "The USE of the Singleton class is still no less
>         global than using static methods."
>         Foo.getInstance().bar();
>         // vs.
>Huge difference...
>                                 -TPP
>This email may contain confidential and privileged material for the sole 
>use of the intended recipient(s). Any review, use, retention, distribution 
>or disclosure by others is strictly prohibited. If you are not the 
>intended recipient (or authorized to receive for the recipient), please 
>contact the sender by reply email and delete all copies of this 
>message.  Also, email is susceptible to data corruption, interception, 
>tampering, unauthorized amendment and viruses. We only send and receive 
>emails on the basis that we are not liable for any such corruption, 
>interception, tampering, amendment or viruses or any consequence thereof.
>To unsubscribe, e-mail:
>For additional commands, e-mail:


This electronic mail  transmission and any accompanying documents contain 
information belonging to the sender which may be confidential and legally 
privileged.  This information is intended only for the use of the 
individual or entity to whom this electronic mail transmission was sent as 
indicated above. If you are not the intended recipient, any disclosure, 
copying, distribution, or action taken in reliance on the contents of the 
information contained in this transmission is strictly prohibited.  If you 
have received this transmission in error, please delete the message.  Thank 

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message