Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint

3.5. Summary

The Singleton focuses on ensuring that only a single instance of a class is instantiated and having global access to the class of the Singleton's origin. While certain aspects of the Singleton appear simple, other features show it to be a subtle and complex design pattern. To be sure, one can find more than one way to design a Singleton, and the ones developed for this chapter certainly have no claim to originality. However, they do represent a very standard implementation of the Singleton, and one that resolves some of the unique elements of ActionScript 3.0 specifically, and ECMAScript more generally.

The Singleton, especially the "classic" model on which we based the ones used in this chapter, has well-reasoned detractors. A short search of design pattern books and articles, including many excellent ones available online, finds many different ideas of how to best design a Singleton class or wholly replace it with a different conceptual structure. The fact that the Singleton provokes such thought has merit in its own right, and we certainly have wrestled with certain limitations ourselves. So if you've got a better Singleton design or better alternative, by all means pursue it.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial