Wednesday, October 28, 2015

Singleton

A Singleton ensures that a class has a single instance and provides a global point of access to that instance.







Check list

  1. Define a private static attribute in the "single instance" class.
  2. Define a public static accessor function in the class.
  3. Do "lazy initialization" (creation on first use) in the accessor function.
  4. Define all constructors to be protected or private.
  5. Clients may only use the accessor function to manipulate the Singleton.

0 comments:

Post a Comment