The intent is to provide a consistent interface for a group of interfaces in the subsystem. The Facade mode defines a high-level interface, which makes the subsystem easier to use. Provide a uniied interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use. Structure participant Facade knows which sub-system classes are responsible for processing requests. Proxy customer requests to appropriate sub-system objects. Subsystem Classes implements sub-system functions. Process the tasks assigned by the Facade object. There is no relevant information about Facade. Facade mode is applicable in the following scenarios: When you want to provide a simple interface for a complex subsystem. There is a large dependency between the implementation part of the client program and the abstract class. When you need to build a layered sub-system, use the Facade mode to define the entry points for each layer of the sub-system. It shields sub-system components from the customer, and the customer program using Facade does not need to directly access sub-system objects. It implements loose coupling between subsystems and customers, while functional components inside the subsystems are usually tightly coupled. If the application needs it, it does not limit the use of sub-system classes. Therefore, you can choose between the ease of use and versatility of the system. The related mode Abstract Factory mode can be used with the Facade mode to provide an interface, which can be used to create subsystem objects in a seed system independent way. Similar to the Facade mode, the Mediator mode abstracts some existing class functions. Mediator aims to abstract any communication between colleagues. It generally does not belong to any single object. The Facade mode only abstracts sub-system interfaces and does not define new functions. Generally, only one Facade object is required. Therefore, you can use the Singleton mode to define the Facade. Implementation Method (1): define a Facade using an abstract class so that sub-classes correspond to different subsystems. Dividing a system into several subsystems helps reduce the complexity of the system. A common design goal is to minimize the communication and dependency between subsystems. In most modes, More and smaller classes are generated. This makes subsystems more reusable and easier to customize, but it also brings some difficulties for users who do not need to customize subsystems. Facade can provide a simple default view, which is sufficient for most users, and users who need more customization can bypass the Facade layer. Abstract classes are used to implement Facade, and specific sub-classes correspond to different sub-systems, which further reduces the coupling between the customer and sub-systems. Copy code 1 namespace FacadePattern. implementation1 2 {3 public abstract class Facade 4 {5 public abstract void Operation (); 6} 7 8 public class ConcreteFacade: Facade 9 {10 public override void Operation () 11 {12 // we cocould use any factory here13 // or use IoC here14 SubsystemClassA subsystemClassA = new SubsystemClassA (); 15 SubsystemClassB subsystemClassB = new SubsystemClassB (); 16 17 subsystemClassA. behaviorA (); 18 subsystemClassB. behaviorB (); 19} 20} 21 22 public class SubsystemClassA23 {24 public void BehaviorA () 25 {26 // do something27} 28} 29 30 public class SubsystemClassB31 {32 public void BehaviorB () 33 {34 // do something35} 36} 37 38 public class Client39 {40 public void TestCase1 () 41 {42 Facade facade = new ConcreteFacade (); 43 facade. operation (); 44} 45} 46}