DDD-based Modern ASP.--ABP Series 3, ABP tiered architecture

Source: Internet
Author: User

Click here to go to the ABP series articles General Catalogue

DDD-based modern ASP. --ABP Series 3, ABP tiered architecture

The ABP is "ASP. Boilerplate Project (ASP. NET Template project) "for short.

ABP's official website :http://www.aspnetboilerplate.com

ABP's Open source project on GitHub : https://github.com/aspnetboilerplate

Objective

In order to reduce complexity and improve the reusability of code, adopting a layered architecture is a widely accepted technique.
To achieve a layered architecture, ABP follows the principles of DDD (domain driven design) and is divided into four levels:

    • presentation Layer (Presentation): Provides a user interface for user interaction.
    • Application Layer (application): Performs the coordination between the presentation layer and the domain layer, and coordinates the business objects to perform the tasks of the specific application. It does not contain business logic.
    • domain layer (domain): Includes business objects and business rules, which are the core layers of an application.
    • infrastructure Layer (Infrastructure): Provides generic technology to support higher tiers. For example, the infrastructure layer Warehousing (Repository) can be used to achieve database interaction through ORM.

Depending on your actual needs, there may be additional layers added. For example:

    • Distributed services Layer (distributed service): Used to expose application interfaces for remote client invocation. For example, through the ASP. NET Web API and WCF.

These are common domain-centric hierarchical architectures. There may be subtle differences in the implementation of different projects.


Architecture of ABP

A simple solution that roughly consists of 5 projects:

Each layer can be implemented with one or more assemblies.

Domain Layer (domain)

The domain layer is the business layer, the core of a project, and all business rules should be implemented at the domain level.

Entities (Entity)
Entities represent the data and operations of the business domain, in practice, by mapping them to database tables.

warehousing (Repository)
Warehousing is used to manipulate databases for data access. Warehousing interfaces are defined in the domain layer, and the implementation class for warehousing should be written on the infrastructure layer.

Domain Services (domain service)
When a business rule is processed that spans two (and more) entities, it should be written in the domain service method.

Domain events (Domain event)
Domain events can be triggered when certain situations occur in the domain layer, and they are captured and processed in the appropriate places.

Working Unit (unit of work)
A work cell is a design pattern that maintains a list of business objects that have been modified, such as additions, deletions, and updates. It is responsible for coordinating the persistence of these business objects and concurrency issues.


Application Layer (application)

The application layer provides some application service (application services) methods for presentation layer invocation. An application service method receives a DTO (data transfer object) as an input parameter, performs a specific domain-level operation using this input parameter, and can return another dto as needed. In the presentation layer to the domain layer, the entity object should not be received or returned, and the DTO mapping should be done. An application service method is generally considered a unit of work. Validation of user input parameters should also be implemented at the application level. ABP provides an infrastructure that makes it easy to implement validation of input parameters. It is recommended to use a tool like AutoMapper to map the entity to the DTO.

Infrastructure Layer (Infrastructure)

When warehousing interfaces are defined in the domain layer, these interfaces should be implemented in the infrastructure layer. You can use ORM tools, such as EntityFramework or NHibernate. The base class for ABP already provides support for both ORM tools. Database migrations are also used in this layer.

Web and Presentation layer (Web & Presentation)

The Web tier is implemented using ASP. NET MVC and Web APIs. Can be used for multi-page applications (MPA) and single-page applications (SPA), respectively.
In the spa, all resources are loaded once into the client browser (or the core resources are loaded first, other resources are lazy to load), and then the server-side Webapi interface is fetched via AJAX, which generates HTML code based on the data. Does not refresh the entire page. Now there are many spa JS frameworks, such as: AngularJs, Durandaljs, Backbonejs, Emberjs. The ABP can use any similar front-end framework, but the ABP provides some help classes that make it easier to use ANGULARJS and Durandaljs.

In a classic multi-page application (MPA), the client makes a request to the server, the server-side code (the ASP. NET MVC Controller) obtains the data from the database, and uses the Razor view to generate the HTML. These are generated after the HTML page is sent back to the client display. Each new page will be refreshed with a full page.

Spas and MPA involve a completely different architecture, as well as a different application scenario. A management background suitable for spa, blog is more suitable for MPA, because it is more conducive to the search engine crawl.

SIGNALR is the perfect tool for sending push notifications from the server to the client. It gives users a rich, real-time experience.

There are already many client-side JavaScript frameworks or libraries, and jquery is one of the most popular, and it has thousands of free plugins. Using bootstrap makes it easier for us to do the work of writing HTML and CSS.

The ABP also implements code functions that automatically create JavaScript based on the Web API interface to simplify JS's invocation of the Web API. And the server side of the menu, language, settings, etc. generated to the JS side. (But in my own project, I turned off these auto-generation functions because the necessity was not very large, and these would have more impact on performance).

The ABP automatically handles the exception returned by the server side and prompts the user with a friendly interface.

Other

The ABP uses Castle Windsor to provide dependency injection functionality for the entire program framework. Use the Log4net logging component to provide other layers of calls to log records.

I hope that more domestic architects will be able to focus on the ABP project, and perhaps it will help you, perhaps with your participation, this project can develop better.

Welcome to add ABP Architecture Design Exchange QQ Group: 134710707

Click here to go to the ABP series articles General Catalogue

DDD-based Modern ASP.--ABP Series 3, ABP tiered architecture

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.