Key Benefits:
1. Provides controlled access to the unique instance.
2, because there is only one object in the system memory, so it can save system resources, for some of the objects need to be created and destroyed frequently the singleton pattern can undoubtedly improve the performance of the system.
3. Allow a variable number of instances.
Main disadvantages:
1, because there is no abstraction layer in the simple interest mode, the expansion of the Singleton class has great difficulty.
2, the single-case category of excessive responsibility, to a certain extent, contrary to the "single principle of responsibility."
3, abuse of a single case will bring some negative problems, such as to save resources to the database connection pool object design as a singleton class, may cause the sharing connection pool object too many programs and a connection pool overflow, if the instantiated object is not exploited for a long time, the system will be considered as garbage, which will result in the loss of object state.
Adapting to the environment:
1, the system only need one instance object
2. A single instance of the client invocation class allows only one public access point, except for that access point, which cannot be accessed by other means.
Beginner This result involves other people's blog content, for reference only! O (∩_∩) o haha ~
Advantages and disadvantages of single-case model and its adaptation environment