(*Just looking back at the title of this Thread*) Just in case someone's wonders; creating a Singleton is nothing new in ActionScript, it can be done in AS1, AS2 or AS3.
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Spike Sent: October 29, 2005 12:25 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] Newbie AS3 question You're welcome! This has been an interesting thread and I've learned a bit more about ActionScript in the process :-) Spike On 10/29/05, JesterXL <[EMAIL PROTECTED]> wrote: > > That makes perfect sense and is a good reason. > > So, from this 2nd conversation, I've gleaned something else to add to the > list: > - getInstance() is a unspoken standard that implies the class is a > Singleton > used in other languages other than ActionScript > - getInstance() treats a class as a true class without static properties, > thus making it easier to go from Singleton to a true class without having > to > change a bunch of code, because all it really does is make 1, and only 1, > instance of itself. > > The thought of changing multiple lines of code to go from static to non > would really suck; that drives the point home for me. Thanks for taking > the > time to explain it Spike! > > ----- Original Message ----- > From: "Spike" <[EMAIL PROTECTED]> > To: "Flashcoders mailing list" <flashcoders@chattyfig.figleaf.com> > Sent: Saturday, October 29, 2005 12:05 PM > Subject: Re: [Flashcoders] Newbie AS3 question > > > It's not necessarily any better from an implementation point of view. You > can often do the same thing with a static class as you can with a > singleton. > > The big benefit comes if you need to change from singleton/static to > different instances for each invocation. > > If you have followed the static class approach you have static method > calls > all through your code that you will need to change if the class now needs > to > be non-static. > > If you have followed the singleton approach, you only need to change the > line of code that retrieves the instance inside the singleton. > > That's a pretty big benefit IMO. > > To get back to where we started all this, the original statement that > brought all this up was your suggestion that > > Foo.someMethod() > > was identical to > > Foo.getInstance().someMethod() > > Whether one is better than another is something that can be debated to > death, and often is on Java mailing lists, but hopefully you'll at least > agree that they are indeed doing different things. > > Spike > > On 10/29/05, JesterXL <[EMAIL PROTECTED]> wrote: > > > > I would have 20 static classes, not 20 if/then/switch statements. You'd > > have that same if/then statement in the getInstance() function, though, > to > > know which formatter to return. > > > > Again, I'm having a hard time seeing why getInstance is more appopriate > > than > > just making static classes, and how this applys to the Singleton > pattern. > > > > > > > _______________________________________________ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > _______________________________________________ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > -- -------------------------------------------- Stephen Milligan Do you do the Badger? http://www.yellowbadger.com Do you cfeclipse? http://www.cfeclipse.org _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders