ABP Tiered Design

Source: Internet
Author: User
Tags app service

ABP Layered Design One, why to layered

Layered architecture is the originator of all architectures, the role of layering is isolation, however, we sometimes have a misunderstanding, that is, the layer and the Assembly, such as a simple three-tier architecture, in your solution, there will typically be three assembly projects: XXUI.dll, XXBLL.dll and XXDAL.dll, and then think of these three assemblies as a layer, which is fine, but when the project is complicated, if you do it in this way, you will have more and more folders in your assembly and the Assembly will become larger. When your field of view jumps out of the concept of the assembly, you will find that the layer is not just the same as the assembly, it corresponds to the solution folder, or the entire solution, and a layer can even correspond to a system.

The purpose of layering is to "high cohesion and low coupling" thinking.

Second, Microsoft Classic three-tier architecture

Any. NET-aware Microsoft three-tier architecture, three-tier architecture is to divide the business into the interface layer (User Interface layer), the business logic layer, the data access layer. Such as

The role of each layer:

interface layer (UI): The main means of Web mode, can also be expressed as WinForm mode, if the logical layer is quite powerful and perfect, no matter how the presentation layer is defined and changed, the logical layer can provide the service perfectly. The request is accepted primarily for the user, and the data is returned.

Business Logic Layer (BLL): mainly for specific problems of operation, can also be understood as the operation of the data layer, the data business logic processing, if the data layer is a building block, the logic layer is the building of these blocks.

Data access Layer (DAL): The main view of the data layer contains no logical processing, in fact, its various functions mainly to complete the operation of the data files. Without having to worry about other operations.

In the eyes of developers, a business system is layered only on the technical architecture, so it will log records, rights Management, database persistence, message services, and so on, some can be separated out as far as possible, and then combine these things together, it became the system help layer, they are implemented throughout the business system.

Three-tier architecture is a typical transaction script logical structure, a complex business is described from beginning to end in the BBL method body, handling highly complex business seems powerless!!!

It is estimated that all. NET programmers are coming from this classic three-tier architecture step-by-step.

Third, DDD Classic layering

DDD: Domain Driven design

TDD: test-driven development

POEAA: Enterprise Application Architecture Model

The core idea of DDD is to control the solution from a database-centric approach to a domain model in the form of a business problem.

Here is a picture of me in the field-driven design and pattern combat book in the film, he fully interprets the classic hierarchy of DDD.

Each layer concept:

Presentation layer (Presentation layer): The user interface layer in the diagram includes the user interface layer, user input, and data presentation.

Application layer (Application layer): The application layer defines the business functions of the system and directs the domain objects in the domain layer to implement these functions.

Domain layer: The core layer that implements all business logic.

Infrastructure layer (Infrastructure layer): Provides the basic services for the entire business system.

class dependencies at compile time for each layer (this is a very short dwarfish-poor diagram):

High-level modules should not rely on the underlying modules, both should be dependent on the abstract

Abstractions should not be dependent on detail, and detail should be dependent on abstraction.

Iv. ABP tiering

FIRSTABP solutions for the previous section:

ABP Detailed tiering:

What do we mean by looking up and down:

Presentation Layer

Presentation:

View Models (Javascript): =

Views (html/css): =

Localization, Navigation, Notifications: Multi-lingual, menu, notification

Web:

Web API Controllers:webapi Interface

MVC Controllers, Odata:odata is what I don't know

Application Layer (application)

Application services: App Service

DTOs: Data Transfer Object

DTO Mappers:automapper mapping between the entity and the DTO

Authorization: Parameter Validation

Session:

Audit Logging: Audit log

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.

Domain layer (domain Core)

Entities: Entities, domain objects, data and operations that represent the business domain

Value objects: Entity model

Repositories: warehousing, used to operate the database 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: A domain service that should be written in the domain service method when the business rules that are processed span two (and more) entities.

Domain event: Domain events that can trigger domain events when certain situations occur in the domain layer, and capture and process them where appropriate.

Unit of work: working unit, 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.

Infrastructure (Infrastructure)

ORM (EntityFramework, NHibernate): ORM Framework, ABP provides EF and NHibernate support

DB Migrations:ef Code first creates a database with the

Background jobs: Job scheduling and automated tasks (similar to quartz.net)

Supplemental (single-page and multi-page applications)

In a single-page application (SPA), all resources are loaded to the client at once (or only core resources are loaded, lazy loading of other resources), and all subsequent and server interactions are invoked through Ajax. The HTML code is generated on the client side using the data received from the server. The entire page is not refreshed, and the view is only swapped in and out when necessary. There are many JavaScript spa frameworks, such as Angularjs,durandaljs,backbonejs and Emberjs. The ABP can use either of them, but it provides examples of using ANGULARJS and Durandaljs.

In a multi-page (classic) application (MPA), the client sends a request to the server, the server-side code (the ASP. NET MVC Controller) fetches the data from the database, and the Razor view engine generates the HTML code. These compiled pages are sent back to the client for display. Each new page will cause a refresh of the full page.

The spa and MPA involve a completely different architecture. For the backend management system, Spa is the best candidate, on the other hand, the blog is more suitable for the MPA model, because the blog is eager to be crawled by the search engine data. Although there are many tools to make the spa visible to search engines, the current general practice is to use MPA.

At last

The ABP balances some of the best frameworks or libraries, and in addition, ABP's own classes and systems provide a good infrastructure for building N-tier Web applications, as well as templates for creating layered solutions that can be used as a starting point for applications.

ABP Tiered Design

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.