C # learning notes for object-oriented design patterns (10)-facade appearance patterns (Structural Patterns)

Source: Internet
Author: User

The problem with the above a solution is that the component customers and various complex subsystems in the component have too many coupling, as external customersProgramWith the evolution of various subsystems, this excessive coupling is faced with many changing challenges.

How to simplify the interaction interfaces between external client programs and systems? How can we decouple the dependency between the evolution of external customer programs and the changes of internal subsystems?

Intention:

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.

 

  Using  System;

Internal Class Wheel
{
Public Void Waction1 (){}
Public Void Waction2 (){}
}

Internal Class Engine
{
Public Void Eaction1 (){}
Public Void Eaction2 (){}
}

Internal Class Bodywork
{
Public Void Baction1 (){}
Public Void Baction2 (){}
}

Internal Class Controller
{
Public Void Caction1 (){}
Public Void Caction2 (){}
}

Public Class Tankfacade
{
Wheel [] Wheels
= New Wheel [ 4 ];
Engine [] Engines
= New Engine [ 4 ];
Bodywork bodywork
= New Bodywork ();
Controller
= New Controller ();

Public Void Start (){}
Public Void Stop (){}
Public Void Run (){}
Public Void Shot (){}
}

 

Key points:

1. From the perspective of the customer program, the facade mode not only simplifies the interface of the entire component system, but also for the 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;

2. Fa C The ade design pattern is not a container and can be put into any number of objects. In the facade mode, components should be "a series of components with relatively large Coupling Relationships", rather than a simple set of functions;

3. Differentiate the facade mode, adapter mode, bridge mode, and decorator mode.

Facade mode focuses on simplified Interfaces,

Adapter mode focuses on the conversion interface,

Bridge Mode focuses on separating interfaces (abstraction) and Its Implementation,

The decorator mode focuses on stable interfaces and extends the object functions..

Applicability: 

1. Provide a simple interface for a complex subsystem;

2. Improve the independence of subsystems;

3. In a hierarchical structure, you can use the facade mode to define the entries for each layer of the system.

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.