Java Design Pattern principle and java Design Pattern Principle
1,Identify the potential changes in the application and separate them from those that do not need to be changed.
In other words, if every new requirement changes some code, you can determine that this part of code needs to be extracted to distinguish it from other stable code.
Or, extract and encapsulate the changed parts so that they can be easily modified or expanded in the future without affecting other parts that do not need to be changed.
2,For interface programming, rather than implementing Programming
"Programming for interfaces" really means "programming for supertypes"
The so-called "interface" has multiple meanings. An interface is a "concept" and a Java interface structure. When Java interfaces are not involved, the key to "programming for interfaces" is polymorphism. With polymorphism, the program can program super-type, and will execute real behaviors according to the actual situation, without being bound to super-type behaviors. The phrase "super-type programming" can be more specifically said "the variable declaration type should be super-type, usually an abstract class or an interface, you can specify this variable as long as it is the object generated by the class that implements this super type ". This also means that when declaring a class, you do not need to care about the real object type during subsequent execution.
"Programming for interfaces" can be well coupled to make code and thinking more layered and facilitate code updates in the future.