Appearance mode: The appearance mode provides a concise and consistent interface to various types (or structures and methods) in the subsystem, which hides the complexity of the subsystem and makes the subsystem easier to use. When a subsystem is complex or complicated, we provide an interface to the subsystem, and other programs or objects connect to this subsystem through this interface. An interface can be a class or method, and so on. This simplifies the use of subsystems.
Simple example:
1 Public InterfaceCamera2 {3 Public voidsetposition ();4 Public voidSetshutter ();5 Public voidsetaperture ();6 Public voidTakephoto ();7 }8 9 Public classSonycameraImplementsCameraTen { One @Override A Public voidsetposition () - { -System.out.println ("Set position ..."); the } - - @Override - Public voidSetshutter () + { -System.out.println ("Set shutter ..."); + } A at @Override - Public voidsetaperture () - { -System.out.println ("Set aperture ..."); - } - in @Override - Public voidTakephoto () to { +System.out.println ("Take photo ..."); - } the } * $ Public classfacadePanax Notoginseng { - Privatecamera camera; the + Publicfacade (camera camera) A { the This. Camera =camera; + } - $ Public voidTakephoto () $ { - camera.setposition (); - Camera.setshutter (); the camera.setaperture (); - Camera.takephoto ();Wuyi } the } - Wu Public classTest - { About Public Static voidMain (string[] args) $ { -Facade facade =NewFacade (NewSonycamera ()); - Facade.takephoto (); - } A}
Appearance mode of Java design pattern