Three-tier B/S system (favorites)

Source: Internet
Author: User
Three-layer B/S structure system development based on UML and ASP. NET Based on UML and ASP. NET Based on B/S structure system development Author: Hu Ying Hui Ning Safei Source: IBM

AbstractGood system analysis and design are the key to software project development. The rationality of Architecture Design often determines the success or failure of the project. This article describes the system modeling process based on UML and the method for implementing an object-oriented three-tier application system based on ASP. NET Based on the development of a project.

 KeywordsASP. NET; three-layer structure; UML modeling; System Development

Architecture Design is the basis of software development and often determines the success or failure of a project. The three-layer architecture is a popular architectural design model. It is developed based on the "layer mode" [1] proposed by Buschmann, it consists of three layers: presentation layer, business logic layer, and data access layer. It manages the complexity of problems through decomposition, and can effectively reuse business logic and retain important connections with expensive resources (such as databases) [2, 3].

Based on ASP. NET, it can make full use of its fully object-oriented technical features to implement a three-layer B/S system architecture, thereby improving development efficiency and enhancing system maintainability and scalability. This article, combined with the development of a "Student Achievement Management System", studies how to model a three-layer B/S Structure System Based on UML and Its Application Implementation under ASP. NET.

 1. Three-tier Structure System Model
Architecture Design is a very advanced design and the key to system design. It mainly defines and describes packages (subsystems) and the dependency and communication mechanisms between packages. The rationality of the system architecture model determines the maintainability, scalability, and development efficiency of the system.

A package usually needs to process either a specific functional area (business logic) or a specific technical area (Technical logic ). The business logic mainly considers the implementation of system business functions, while the technical logic further considers the technical solutions formed by user interfaces, databases, or communication mechanisms. It is extremely important to distinguish the technical logic from the business logic, so that when a part of the program is modified, it will not affect the other part, making it easier to "reuse ", at the same time, it is easy to respond to changes from the business logic.

A layer-3 architecture is a mature, simple, and widely used application architecture. It divides the application structure into three independent packages, including the user presentation layer, business logic layer, and data access layer. Put all forms and components that implement man-machine interfaces in the presentation layer, and encapsulate the implementation of all business rules and logic in the components responsible for the business logic, encapsulate all interactions with the database in the data access component. The structure is shown in 1:

 Figure 1 three-tier structure

A layer-3 structure is a strictly hierarchical method, that is, the data access layer can only be accessed by the business logic layer, and the business logic layer can only be accessed by the presentation layer. Users send requests to the business logic layer through the presentation layer, the business logic layer completes the relevant business rules and logic, accesses the database through the data access layer to obtain data, and then returns the data in reverse order to display the data in the presentation layer.

 3-layer B/S structure Student Management System Development
The following describes the complete development process from UML modeling to ASP. NET-based B/S structure system through the development of a student management system. The UML modeling tool uses Rational Rose.

2.1 Requirement Analysis
Software Requirement analysis is the first and most important part of system development. Its basic task is to answer "what is the system doing?" accurately ?" This problem requires in-depth understanding and description of the functional, performance, interface, and other requirements of the software on the basis of a thorough investigation of user needs, you can use UML modeling as an effective method for requirement analysis and system design.

The purpose of analysis is to obtain and describe all the requirements of the system. Therefore, the analysis stage is a typical process of cooperation with users or customers, usually completed by developers with users or customers. At this stage, developers should not consider the code or program implementation details, but should focus on understanding the existing business logic and fully communicate with users, gradually understand and describe the user-confirmed system model, including the case model and domain (key class in the system) model.

2.1.1 Use Case Model

In the process of researching user requirements, software developers often cannot immediately and accurately describe what functions the system should provide in the future. Therefore, developers need to understand and analyze the requirements, and intuitively describe the functions that the system should have through the use case diagram, so that users can understand and judge, developers can constantly adjust the use case model based on user feedback until the system functions are fully correctly and clearly described.

Case modeling mainly separates the active actors and Use Cases of the system. Use Cases refer to a description of the functions provided by the system, activity participants are people or external systems who may use these cases. The use case diagram can be used to describe the executors outside the system, the use cases of the system, and the relationships between them. The usage diagram of the student management system is shown in figure 2.

The Use Case model also needs to further describe each use case in detail, further describe the use case name, basic event stream and alternative event stream, preconditions and post conditions, and form a document. I will not talk about it here.
Figure 2 use case diagram

2.1.2 Domain Modeling
In the analysis process, fields (domain, key classes in the System) must be listed in detail. To conduct domain analysis, we need to fully understand the use case model, you can also organize a collective seminar with users and domain experts to find out all the key concepts that must be processed and their relationships, and finally analyze the domain class diagrams. 3 is the domain class diagram of this system.

It should be emphasized that at this stage, the class diagrams for analysis of the domain are still in the "sketch" state. The defined operations and attributes are not the final version, but are suitable for this stage. In the future, new operations will be continuously developed through dynamic behavior analysis, which is a process of gradual improvement and development.

2.2 System Design
The purpose of the system design is to generate an available and complete solution and easily convert the solution into program code. In this phase, based on the three-layer architecture design model, all implementation technical issues will be taken into account, the models in the analysis phase will be expanded and refined, and the classes defined in the analysis phase will be further expanded, define new classes to deal with technical issues and form the final UML model.

The method for promoting continuous and detailed design is to dynamically model each use case and describe how to implement the functions in the use case through object collaboration in the class diagram. because of the insufficient understanding of the system at the beginning, the classes created earlier often go deep in Dynamic Modeling and find defects or incomplete ones. Therefore, you need to constantly modify and adjust the domain class diagrams obtained in the analysis to expand and form the business logic package. At the same time, with in-depth modeling of user interfaces, database access and other technologies, we constantly create new user interface classes (such as forms and controls) and data interfaces, form the user interface package and data access package.

After the student management system is designed in detail, the expanded business logic package diagram is shown in Figure 4.
Figure 3 domain class diagram

 Figure 4 business logic package diagram

Figure 5 shows the newly created data access package. All data connector Classes define a base class DBCommon. This base class contains the DBConnectionString attribute, which can be used to obtain the database connection string. It also includes the GetDataView method, which can be used to execute queries in the database to obtain a DataView. These attributes and methods are inherited by all data handler classes and can be directly used.

Figure 5 data access package

The class diagram of the user interface package is relatively simple, mainly through the interface design, design the interface elements such as forms and controls, and according to the user interface access actions required for dynamic modeling, the related events caused by the definition are all defined in the Form class and made up the user interface package. This is not detailed here.
Dynamic Modeling usually uses a sequence diagram in UML to describe the use case. A Sequence diagram analyzes a "scenario" in a specific use case. The so-called "scenario" refers to the course of Event Development in a use case. According to the different input or behavior of the activity participants, a single use case usually has multiple "scenarios", and multiple sequence diagrams need to be analyzed. The time sequence diagram is used to describe the communication between objects in a scenario. At the same time, you can analyze the operations required for the corresponding classes in the system, so as to continuously expand and refine the class design. If you need to further describe the status change and operation process of the class, you can use the state diagram and activity diagram in UML.

Figure 6 logon scenarios

There are many sequence diagrams generated during dynamic modeling, which cannot be described in detail here. Figure 6 shows the sequence of Logon system scenarios. A LoginForm class is defined in the user interface package. The corresponding Web form is Login on the user Login form page. aspx, figure 6 describes how to implement user logon in this form.

2.3 System Implementation Based on ASP. NET
In the previous system design of the dynamic model, the time sequence diagram has been used to describe the scenarios involved in the functions of each use case in detail. According to the time sequence diagram, each use case can be encoded separately. The following describes how to implement the System Based on ASP. NET Based on the "Logon System" case in the student management system.
First, we need to consider subcontracting. The corresponding namespace in ASP. NET is used. In this student management system, set the namespace of the business logic package to ResultManage. businessRule. The namespace of the data access package is ResultManage. dataAccess, And the namespace of the user interface package is ResultManage. web.

Then, design the related classes in the business logic package and data access package. For the "Login System" use case, we can see from the 6 login scenario timing diagram, related classes include the Users class of the business logic package and the UsersDB class of the data access package. The attributes and methods of these classes are defined and implemented respectively, design some test cases or programs to perform unit tests.

Finally, according to the user interface package and the rules in the 6 logon scenario sequence diagram, design and implement the Login. aspx on the user Login form page. The Login code is as follows:

Private void btnLogin_Click (object sender, System. EventArgs e)
// Obtain user logon information
String UserName = txbUserName. Text;
String Password = txbPassword. Text;
If (Users. Login (UserName, Password) // check user logon information
// Create an authentication ticket
FormsAuthentication. SetAuthCookie (UserName, false );
// Display the welcome information
ShowWelcomeMessage (UserName );
Message. Text = "User Logon Failed! ";
Catch (SqlException sqlexception)
// Prompt database operation error message
Response. Write (sqlexception. Message );
In the code, you can call the Users Login method of the business logic package to check the Login information. The Code is as follows:
Public static bool Login (string UserName, string Password)
If (UserName = "")
Return false;
// Check whether there are qualified users in the database
Return UsersDB. CheckLogin (UserName, Password );

In the code of the above-mentioned Users Login method, the business logic is checked first to determine whether the user name is empty. If the user name is involved in database access, it is completed through the data logging class, use the CheckLogin method of the UsersDB class of the data access package to check whether there is a user that meets the corresponding login information from the database.

As mentioned above, all classes in the data access layer, including the UsersDB class, are inherited from a base class DBCommon, which encapsulates the common features of all database Metadata classes, this includes defining the public attribute: data connection string DBConnectionString. Use DBConnectionString in the CheckLogin method of UsersDB to connect to the database, and call the Stored Procedure CheckLogin in the database to check whether the user logon information is correct.

 3 conclusion
This article introduces the UML modeling and ASP-based B/S structure system. NET implementation process and method, the implementation of the three-layer structure not only the program logic structure is clear, but also due to the ease of change in the business logic part of the implementation of the separation, therefore, it has higher scalability and maintainability. At the same time, this system is highly flexible in deployment. You can compile each package into A. NET Component and install it on multiple servers. Typically, the user interface package is installed on the Web server, the business logic package is installed on the application server, and the data access package is installed on the database server or further separated to achieve multi-level distributed deployment, to achieve better scalability and security, and meet the needs of large-scale enterprise B/S application systems.

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: 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.