The underlying logic layer initiates and data flows to the upper-level logic layer in several ways

Source: Internet
Author: User

Business environment background:

Data receiving LayerReceivedDataAndData operation layerTransfer.

 

Method 1 Event Mode (note that this mode is asynchronous)

Generate an event corresponding to the data at the data receiving layer,

The data operation layer listens for events and processes them accordingly.

Features: Asynchronous mode, low coupling, one-to-multiple

 

The second method of delegation (note that this method is synchronous)

At the data receiving layer:

Define the data processing delegate at the data receiving layer.

After receiving data, call the defined data processing delegate interface.

Data Processing Layer: In the initial data receiving layer, the data operation is passed to the delegate interface of the Data receiving layer.

 

Features: Synchronous mode, high coupling, one-to-one

 

The third method is the observer mode, which defines the processing interface (note that this method is synchronous)

At the data receiving layer:

Define a processing interface at the data receiving Layer

After the data receiving layer obtains the data, it calls the processing class interface directly.

Data Processing Layer:

Define a data processing class that inherits the processing class interface of the Data receiving layer.

When initializing the data receiving layer, pass the data processing class to the data receiving layer.

Can be modified to asynchronous mode

 

Features: Synchronous mode, with a general Coupling Degree, one-to-one

 

 

 

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.