incubator-flex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Omar Gonzalez <>
Subject Re: [RT] From Singletons to Unit-testable code
Date Wed, 08 Feb 2012 03:27:46 GMT
> And then there is the whole debate about Singletons in general...
> --
> Alex Harui
> Flex SDK Team
> Adobe Systems, Inc.
I don't think the issue a lot of devs have with Singletons is actually with
the concept of Singletons itself but the implementation in which most
Singletons are written. There's a reason why IoC containers like
SwiftSuspenders have a mapSingleton() method, and that's because the
concept of a class that should ever only have a single instance is valid
and necessary, but when this is enforced with static properties with the
traditional constructor enforcement and getInstance() static functions it
really hinders the ability to create mock objects when trying to right
clean, truly isolated unit tests. Managing the singleton aspects of classes
using an IoC container ensures that you have a single instance of a class
type but are able to swap out the implementation whether it be for testing
or extending a code base. I could be wrong, I've been wrong lots before
heh, but those are just my thoughts on it.


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message