the record of Design Pattern Learning
Create a global access class for Setting or thread managing ... etc.
It uses a static variable, a private constructor and a public static function - getInstance()
to make sure that only one instance of class exists.
Decouple the object request the command and perform the command.
It uses a command interface with execute action, and through invoker to active the command behavior.
Make interface convert to another interface.
It uses a adapter class to turn the original interface to the new one.
Don't provide unnecessary information for client to operate and make client code as simple as possible.
It uses a facade interface to restructure a set of complex interfaces. It makes the facade interface only provide necessary operate functions for clients.
Decouple low-level & high-level components. make high-level decide algorithms and low-level decide the detail of different class.
It use an abstract class with functions to build algorithms. When concrete class inherits the abstract class, it can overwrite some of these classes to provide flexibility for different classes.
Through a common interface for traversing the data in any aggregate data structure (ex. array, vector, link list, hash map, etc.)
It use a interface called Iterator with function - hasNext() & next() to implement traverse feature. Make the aggregate to implement the Iterator interface by themselves. Thus, every aggregate supporting Iterator have the traverse feature.
Make clients treat individual objects and compositions of objects uniformly.
It puts individual objects and compositions of objects into a tree structure, so that it can handle both in same structure.
The implement of finite-state machines.
It uses a point of current state. Through changing the current state to do different behavior in same function.
Help to structure the program for user interface.
It is composed of Observer, Strategy, and Composite patterns. The Model uses the Observer pattern for the view. Through the Observer pattern, the view can receive the notice from the model when a value changed. The Controller uses the Strategy pattern for the view. Through the Observer pattern, the view can choose other controllers for implementing the different behavior. The view uses the composite pattern to combine and operate components in the user interface.