Patterns
The following document is the first honest attempt on my part to understand patterns. I am using as reference.
Creational Patterns
The following document is the first honest attempt on my part to understand patterns. I am using as reference.
Creational Patterns
- Singleton : One instance of a class and accessible globally
Features :- Ensure unique instance by defining class final to prevent cloning.
- May be extensible by the subclass by defining subclass final.
- Make a method or a variable public or/and static.
- Access to the instance by the way you provided.
- Well control the instantiation of a class
- To design a Singleton class, you may need to make the class final like java.Math, which is not allowed to subclass, or make a variable or method public and/or static, or make all constructors private to prevent the compiler from creating a default one.
Examples
One file system, one window manager, one printer spooler and etc.