Suppose you want to create a message board in this structure:
# Appearance of the message board page Code All are stored in the. aspx file.
# When a user clicks the submit button on the page, the text information is first transmitted to a leaveword Class Object
(The leaveword class definition is encapsulated into the "business logic layer ")
# Then let this object execute post () to send the message to the database
a simple code is:
// ----------------------------------------
// on the appearance layer, after you click the send button,
// users
private void post_serverclick (Object sender, eventargs e)
{< br> leaveword lword = new leaveword ();
lword. content = content. value;
lword. post ();
}< br> // ----------------------------------------
// on the business logic layer, define the leaveword class
// --------------------------------------
public class leaveword
{< br> Public String content;
Public void post ()
{< br> New lworddata (). post (this. content);
}< BR >}< br> // ------------------------------------------
// database layer, define the sending method
// --------------------------------------
public class lworddata
{< br> Public void post (string content)
{< br> // open the database and insert content into the table
}< BR >}< br>, the appearance layer does not have to worry about database operations...
Understanding is basically correct. However, the data layer is only a database operation and should not have any relationship with the business. You can refer to sqlhelper. CS
Note that the "layer" of the system is a logical division of code, not three layers are required. Assume that your system is very simple, just a page, and that layer is fine, if the system is complex, it may be N layers.
The core is that the outer layer will never involve any data processing. Its task is to set the interface, get data, and output data.
The business layer is the most important. All data processing here, how to use the data processing services provided by the outer layer
We recommend that you call the stored procedure at the database layer to return a dataset or other required data. The two examples of. NET are good. Learn more.
One principle:
Upper-level lower-level adjustment
The upper layer is invisible to the lower layer.
During the design, the presentation layer only calls the logic layer. The presentation layer mainly obtains the page data and transmits it to the logic layer, and displays the data obtained from the logic layer to the page.
The logic layer completes Data Processing and uploads data to the data layer and processes the data obtained from the data layer.
The data layer is only responsible for database operations
The business logic layer is the middle layer for issuing commands and adjusting behaviors to the upper and lower layers. Is that easy to understand?
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/21aspnet/archive/2007/03/24/1540030.aspx