View Full Version : Singleton vs. Static methods
praufet
03-02-2007, 05:55 AM
I don't really get what the point of a singleton over a class with static properties/methods is? Can anyone explain it to me?
daryl
03-05-2007, 07:56 PM
I don't really get what the point of a singleton over a class with static properties/methods is? Can anyone explain it to me?
You can get the same functionality in either a static class and a singleton. There are some subtle differences.
Singletons are better in cases where you want to
- limit the number of resources avail at a time (pooling)
- be able to extend the singleton class
- be sure the class has been initialized, if necessary, via the constructor.
or if its a view item, as you need to create an instance.
praufet
03-07-2007, 04:39 AM
Ya I coincidently just read about the difference in Actionscript 3 with Design Patterns.
generally i would only use a static class as a utils class, with method i can pass stuff to and get something back (like the Math class). I generally wouldn't use one in a case where it actually has to store some data.
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.