1. Appearance mode (facade)
Know the principle at least: a class should interact with the other classes as little as possible , making the classes relatively independent and the system functional modules relatively independent.
Definition: Reduce the dependency between classes and classes, just like spring, you can configure relationships between classes and classes into a configuration file .
The appearance pattern is to put the relationship between their classes in a facade class , reducing the coupling between classes and classes, which does not involve interfaces.
2. Illustrations
public class Computer {//Individual parts (classes) Private CPU Cpu=new CPU ();p rivate memory M=new memory ();p rivate disk d=new disk ();p u Blic static void Main (string[] args) {//TODO auto-generated method stub computer cp=new computer (); Cp.start (); Cp.shutdown ();} Computer starts public void start () {Cpu.start (); M.start (); D.start (); SYSTEM.OUT.PRINTLN ("Computer is up and ready"); }//Computer off public void shutdown () {cpu.shutdown (); M.shutdown (); D.shutdown (); SYSTEM.OUT.PRINTLN ("Computer complete shutdown"); }}class CPU {public void start () {System.out.println ("CPU boot ..."); } public void Shutdown () {System.out.println ("CPU off ..."); }}class memory{public void Start () {System.out.println ("Memory start ..."); } public void Shutdown () {System.out.println ("Memory closed ..."); }}class disk{public void Start () {System.out.println ("Hard disk boot ..."); } public void Shutdown () {System.out.println ("hard disk closed ..."); }}
Operation Result:
CPU boot ... Memory boot ... Hard Drive Boot ... CPU off after computer starts ... Memory off ... Hard drive off ...
java-design mode (structural type)-"appearance mode"