I have recently started doing some ActionScript/Flex programming and I am… Surprised… By the number of singletons I see. They are everywhere! The standard library, the frameworks… Heck, I even read a blog post this morning where the author mentioned that he refactored some of his classes INTO singletons!
Is there any reasonable explanation for why the AS community likes singletons so much?
It’s not just the AS community, it’s a general trend in software design. Component-oriented programming encourages the initial setup and wiring of service objects, which then collaborate using transient messages. Singletons are a natural part of this idea.
Also singletons reduce the runtime impact of objects that are expensive to create.