Definition: Facade, which provides a consistent interface for a group of interfaces in the subsystem, defines a high-level interface, which makes this subsystem easier to use.
Features:
(1) The loose coupling relationship between the subsystem and the client is realized.
(2) The client blocks subsystem components, reduces the number of objects that the client needs to process, and makes the subsystem easier to use.
Enterprise-level development and commonly used framework heavy applications: many, such as common string segmentation methods, spilt, are also
Specific examples :
package com.test.faced;/** * Take tea as an example: If we want to drink tea, we must have tea sets, tea leaves, tea cooking tools, etc.*/public class Demo { public static void main(String[] args) { System.out.println("When the appearance mode is not used, these objects need to be prepared by the customer"); Tea tea = new Tea("Longjing"); TeaSet teaSet = new TeaSet(); TeaTools teaTools = new TeaTools(); System.out.println("Drinking tea"); System.out.println("Use appearance mode, we provide a teahouse object:"); TeaHouse teaHouse = new TeaHouse(); teaHouse.drinkTead(); System.out.println("Drinking tea"); }}class Tea{ public Tea(String name) { System.out.println("Prepare the tea to drink: "+name); }}class TeaSet{ public TeaSet() { System.out.println("Prepare the tea set to drink tea"); }}class TeaTools{ public TeaTools() { System.out.println("Tools to prepare tea, cook tea"); }}class TeaHouse{ public void drinkTead(){ Tea tea = new Tea("Longjing"); TeaSet teaSet = new TeaSet(); TeaTools teaTools = new TeaTools(); System.out.println("Please drink tea"); }}In fact, the appearance mode is similar to the packaging concept we often mention. Encapsulation means encapsulating objects, while the appearance mode means encapsulating complex processes and providing a unified interface to the outside world, so that users do not have to worry about the entire complex process and only pay attention to the process processing results.
The above is all the content of this article. I hope it will be helpful to everyone's learning and I hope everyone will support Wulin.com more.