1. Singleton mode: For the entire life cycle of an application, only one instance of the Singleton class is available and is automatically instantiated. The constructor method for a singleton class must be private and provide a global access point
public class Test { private test () {} private static test uniqueinstance = new test (); public static Test Getuniqueinstance () { return uniqueinstance; }}
2. Factory mode:
(1) Simple Factory mode: The factory class can return instances of a class in several possible products according to the parameters supplied to him
(2) Factory method mode: Defines an interface for creating a factory class for the Product object, and then defers the creation to the subclass of the factory interface
3. Adapter mode: Because the interface does not match the two classes that do not work, through the adapter class can be returned to the client based on the parameters passed to a suitable instance
4. Observer mode: An object can be observed by adding a method. When an observable object changes, he publishes the message to the registered observer, which observes that the information can be related to the operation.
A simple summary of Java design patterns