>
> And then there is the whole debate about Singletons in general...
> --
> Alex Harui
> Flex SDK Team
> Adobe Systems, Inc.
> http://blogs.adobe.com/aharui
>
>
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.

-omar

Reply via email to