The Artima Developer Community
Sponsored Link

Legacy Design Forum
Designing with Static Members

Advertisement

Advertisement

This page contains an archived post to the Design Forum (formerly called the Flexible Java Forum) made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

java java

Posted by bhavesh on July 09, 2000 at 2:16 AM

> > > The whole notion of statics and Singletons is really a nightmare in Java, especially in the applet world. When two applets are on the same page and have classes that contain Singletons or statics, those values are reflected in _both_ applets not on a per applet instance basis as one would think (hope). I think that Java is greatly lacking in this support and I imagine there is no effort to have better support. :(

> >
> > I tend to disagree with your view that two applets share
> > the static variables of the class. As far as I know, each
> > applet is loaded by a separate ClassLoader, and live in
> > separate namespaces. There is no question of conflict here,
> > and the static variables (class variables) do not have
> > the same values (except possibly at class initialization).

> > Statics and singletons play a crucial role in OO design.
> > E.g: Factory pattern.

> > Java provides a whole lot more support than what people
> > assume or think. Classloaders, security managers, access
> > controllers play an important role in client-side design
> > and development.

> > regards,
> > Raghu

> If you examine some of the Swing code, you'll see that they
> realize the short coming of Singletons/statics. They hash
> on some particular Applet ID, etc when they actually refernce a
> static/Singleton....





Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us