11. Facade appearance [facade mode] (Structural Mode)

Source: Internet
Author: User
Intent)
Provides a consistent interface for a group of interfaces in the subsystem. The Fa-ade mode defines a high-level interface, which makes the subsystem easier to use.
-- Design Pattern gof
 

The following figures are just my own understanding of software products.
 
Two meanings of the facade mode: 1. Simplicity 2. Decoupling

Using system;
Using system. Collections. Generic;
Using system. LINQ;
Using system. text;

Namespace Facade
{
Function implementation (not concerned with subsystem implementation) # region function implementation (not concerned with subsystem implementation)

Public Class Wheel
{
Public void waction1 ()
{

}
Public void wacation2 ()
{

}
}
Public class Engine
{
Public void eaction1 ()
{

}
Public void eaction2 ()
{

}
}

Public class bodywork
{
Public void baction1 ()
{

}
Public void baction2 ()
{

}
}

Public class Controller
{
Public void caction1 ()
{

}
Public void caction2 ()
{

}
}
# Endregion

High-level interface (aggregation of all functions) [The external type can only be used for this type] # region high-level interface (aggregation of all functions) [The external type can only be used for this type]

/** // <Summary>
/// Interface: indicates that the interface is exposed. it is not necessarily an interface definition. The method starting with "public" is also an interface (exposed). It must comply with the single responsibility principle and combine related functions.
/// </Summary>
Public class tankfacade
{
Wheel [] wheel = new wheel [4];
Engine [] Engine = new engine [4];
Bodywork bodywork = new bodywork ();
Controller controller = new controller ();


Public void start ()
{

}
Public void stop ()
{

}
Public void run ()
{

}
Public void shot ()
{

}

}
# Endregion

Customer Program (calling high-level module) # region customer Program (calling high-level module)

Class Program
{
Static void main (string [] ARGs)
{
}
}

# Endregion
}

Structure)
 

Several highlights of the facade Mode
• From the perspective of the customer program, the facade mode not only simplifies the interface of the entire component system, but also for internal and external customer programs of the component, to some extent, it achieves a "decoupling" effect-any changes to the internal subsystem will not affect the changes to the fa c Ade interface.
• The Fa C ade design model focuses more on the entire system from the architectural hierarchy, rather than the individual class hierarchy. Fa C Ade is often an architectural design model.
• Be sure to differentiate the fa c Ade mode, adapter mode, bridge mode, and decorator mode. The FA-ade mode focuses on simplified interfaces, the adapter mode focuses on the conversion interfaces, and the bridge mode focuses on the separation of interfaces (abstraction) and their implementation. The decorator mode focuses on the object extension function on the premise of a stable interface.
Note that the facade mode cannot undermine the single principle of software. Aggregate a set of related functions!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.