Singletons can get confusing once your application is separated into
functional modules,
sometimes you may want to have a 'singleton', but only within the scope of
a functional module.
If you don't use some kind of dependency injection container that takes
care of this scoping
things can become quite complicated.
So, there is certainly nothing wrong with the concept of a singleton, but
the way that is implemented
in some Actionscript frameworks makes it rather rigid.  I mean this kind of
code:

MySingletonClass.getInstance()

Which in a unit testing scenario is a nightmare. In general, static
functions might even be considered a
code smell. (But I'm sure folks can come up with scenario's where they are
perfectly suitable).

Roland

On 16 January 2013 14:51, Edouard <edouardbatai...@gmail.com> wrote:

> In case of Module wich are load and unload, Singleton can be a huge problem
> for memory leaks
>
>
> On Wed, Jan 16, 2013 at 2:46 PM, Harbs <harbs.li...@gmail.com> wrote:
>
> > Well, I've never done unit testing, so maybe that explains why I don't
> > "get it"…
> >
> > On Jan 16, 2013, at 3:39 PM, Michael Schmalle wrote:
> >
> > > IMHO;
> > >
> > > Singletons serve a purpose just like every other design pattern. Having
> > developed/architected quite large frameworks in my day, Singletons are
> evil
> > in the context of a framework. You will soon see when you start unit
> > testing how evil they are. (IE I put one in FalconJx temporarily to stop
> > jsdocs from being emitted in the unit tests, now that damn thing is all
> > over the tests and I have to kill it)
> > >
> > > As far as applications, I believe it's really up to the developer
> > because they program what they were taught and familiar with.
> > >
> > > Mike
> > >
> > > Quoting Harbs <harbs.li...@gmail.com>:
> > >
> > >> Over the years I'm heard this from time to time, but I never
> understood
> > the prejudice. I personally like singletons because it keeps things nice
> > and simple. I don't like over-engineering things for no reason.
> > >>
> > >> Care to explain what's wrong with singletons?
> > >>
> > >> On Jan 16, 2013, at 8:41 AM, Avi Kessner wrote:
> > >>
> > >>> I'm in the 'singletons are evil' camp.
> > >>
> > >>
> > >
> > > --
> > > Michael Schmalle - Teoti Graphix, LLC
> > > http://www.teotigraphix.com
> > > http://blog.teotigraphix.com
> > >
> >
> >
>
>
> --
> Edouard Bataille
> Epita MTI 2008
> Consultant Expert Java Flex
>



-- 
regards,
Roland

-- 
Roland Zwaga
Senior Consultant | Stack & Heap BVBA

+32 (0)486 16 12 62 | rol...@stackandheap.com | http://www.stackandheap.com

http://zwaga.blogspot.com
http://www.springactionscript.org
http://www.as3commons.org

Reply via email to