Don’t understand Design pattern by language. Such as factory method
and template method, They share the same language structure( class
inheritance and structure). But their context is different.
Three use recursive: composite, decorator, chain of responsibility and
Interpreter.
Bridge , abstractor factory and visitor have same points, they all have
parallel two inheritance system, there is a relationship between two
systems.
Template method and Factory method are both pull up commonand push down change. Template pull up common algorithm steps
and Create templateMethod(). And Factory method pull up common
produced procession and Create factoryMethod.
Sometimes, You want to pull up common. But there is NO concrete
conception(A noun) waiting here, then you can abstract a conception, and
make an abstract class as base class.
Button and applicaition should not have baseclass, but they both
support requestHandle(), So you create Handler class.
Textview and decorator should not have base class, but after
decoration, textview is still textview. So I create VisualComponent
Base class.
In Mediator pattern. Listbox and EntryField have now common
baseclass, So create Colleague baseclass.
Proxy is also follow this idea.
Program to interface. But where are interfaces?
You can pull up to create baseclass interface: such as component,chain of responsible, decorator and proxy.
You can create a medium class(interface) . such as command
between invoker and Receiver, Memento between Originator
and caretaker. adapter between Target and Adaptee. Mediator
between Colleague and ConcreteMediator.
Iterator between container and algorithms. builder between
Director and product.