Business Layer Architecture Pattern

Source: Internet
Author: User

A: Overview of the Business Layer architecture model

In a three-tier architecture, the business layer is responsible for all business-related work, including calculations based on input data or existing data, validation of data entered from the presentation layer, and determining which data access logic should be invoked based on commands received from the presentation layer. For the application system, the business layer mainly maintains the business logic and is the core part of the system . Therefore, in the application system development, the development of the business layer is the most critical.

There are several architectural patterns for the business layer, most notably the following two: Transactional scripting Model (process-oriented design) domain model (object-oriented design) Two: Transaction script model Transaction script (Transaction scripts) schema model is the traditional way to organize business logic, It organizes the business logic of the business layer into a series of transactional scripts, each of which is a way to access the database and perform calculations, each of which processes a single request from the presentation layer. Transactional scripts are usually grouped together to form a transactional scripting class to implement business logic for one or more use cases. When you use transactional scripting to organize business logic, the business layer structure consists of three parts: the transaction script: The transaction script class consists of several methods, and one method corresponds to a transaction script, which corresponds to a user request. DTO: Transaction Script class operations DTOs (Data Transfer object, data transfer objects). DTOs have only member variables and no methods. It contains data from the database and is returned to the presentation layer by a transactional script. Entity class DAO: Transaction script accesses the database using DAO in order to understand the transaction script schema pattern more clearly, we develop a simple employee management system as an example, today's job is this! To add a query based on the condition. The process of developing business logic based on the transaction script pattern consists of four steps: 1) identify transaction scripts, identify transaction scripts can analyze use cases or analyze user interface prototypes, in which the analysis of user interface prototypes is most straightforward.

2) Implement the transaction script; Now we have identified the transaction scripts and determined their parameters and return value types. The next step in the process, then, is to implement the transactional scripting interface.

3) implement a dto; a DTO is passed between the transaction script and the DAO, as well as between the transaction script and the presentation layer. DAO uses DTOs to return data that needs to be fetched from the database to the transactional script, and the transaction script uses DTOs to pass data to DAO to update the database. The transaction script also returns the DTO to the presentation layer.

DTOs only save data, only member variables and Setter/getter methods. DTOs and their member variables can be judged by combining the following three identification techniques:

Define a DTO,DTO member variable for each database entity table that corresponds to the column of the table.

A member variable that defines a dto,dto for each user interface contains the data that is displayed on the screen. Use simple OO analysis and design techniques to identify classes and their member variables.

4) Implement DAO. Each DAO consists of an interface and an implementation class. In the previous chapter we have learned how to implement DAO. Not in detail here, only the DAO interface and implementation Class code of the simple Employee management system is listed.

The biggest advantage of transactional scripting is its ease of use. Because of the process design, a user requests a transaction script, users do not have the OO design skills, do not recognize the class and assign responsibilities to the class, any beginner can quickly grasp the transaction script mode to organize business logic method. Cons: Because transactional scripting is a process-based approach, all business logic is focused on transactional scripting. It is clear that the business logic is concentrated in the transaction script, violating the design principles of single responsibility in object-oriented design. This makes code difficult to maintain and understand, especially when business logic is complex. Although the transactional scripting model has drawbacks, there are still many development teams that use this pattern to organize business logic at the business level. When the business logic is relatively simple, the use of Transaction scripting mode can greatly accelerate the development progress. Also, if the development team lacks object-oriented design skills, adopting a transactional scripting model is also a sensible choice.

Business Layer Architecture Pattern

Related Article

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.