[Note] layer-3 architecture + Event Delegation

Source: Internet
Author: User

The entire business application is divided into: Performance layer (USI), business logic layer (BLL), and data access layer (DAL ). The purpose of hierarchy differentiation is the idea of "high cohesion and low coupling.

The data access layer DAL (DataAccessLayer) is mainly used to access the database and perform operations to add, delete, and modify the database.

Performance layer (USI), closest to the user. It is used to display data and receive user input data, providing users with an interactive operation interface.
Business logic layer (BLL): For the data access layer, it is the caller; for the presentation layer, it is the caller

Presentation Layer: Located in the outermost layer, closest to the user, used to display data and receive user input data, provides users with an interactive operation interface.

Business logic layer: a bridge between the presentation layer and the data access layer. It is mainly responsible for data transmission and processing, such as data validity check, business logic description, and other related functions.

Data access layer: stores and reads data. Data access allows access to relational databases, text files, XML files, etc. The data access layer is usually a class library.

Experience Sharing:

1. In the layer-3 structure, the dependency between layers is that the presentation layer depends on the business logic layer, and the business logic layer depends on the data access layer.

2. The presentation layer only allows reference to the business logic layer and does not allow direct application of the data access layer.

3. circular reference is not allowed between projects at different layers.

 

Event Delegate:

Delegate function reference:
Delegate int SomeDelegate (string s, bool B );
It is a delegate statement. Here, the signature mentioned is SomeDelegate.

When you instantiate a delegate, you need to provide a reference function that serves as a parameter for its constructor. Note: The referenced function must have the same signature as the delegate.
Example: private int SomeFunction (string str, bool bln ){...}

You can pass this function to the SomeDelegate constructor because they have similar signatures (they all have the same parameter type and number and return the same data type ).
SomeDelegate sd = new SomeDelegate (SomeFunction );

Sd references SomeFunction
Delegate int SomeDelegate (string s, bool B );
Private int SomeFunction (string str, bool bln ){...}
SomeDelegate sd = new SomeDelegate (SomeFunction );

Events are delegate-type variables. Use the event keyword and the delegate type to declare it, as shown below:
NumberReachedEventHandle is only a delegate
Public event NumberReachedEventHandler NumberReached;

 

Jimmyzhang
A delegate is a class that defines the type of a method so that the method can be passed as a parameter of another method. This way, the method is dynamically assigned to the parameter, it can avoid using the If-Else (Switch) statement in a large number in the program, and make the program more scalable.

 

 

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.