Backend Development 8 min read

Application Layering Best Practices and Alibaba Specification

The article explains common misconceptions about application layering, presents Alibaba's multi‑layer architecture (open‑interface, terminal display, web, service, manager, DAO), proposes an optimized layering model with RPC, and discusses domain‑model conversions such as DO, DTO, BO, AO, VO and Query to achieve clear responsibilities and maintainable code.

Big Data Technology Architecture
Big Data Technology Architecture
Big Data Technology Architecture
Application Layering Best Practices and Alibaba Specification

1. Background Many developers treat application layering as a simple three‑tier structure (controller, service, mapper) without clearly separating responsibilities, leading to tangled code, poor reusability, and maintenance difficulties.

Key requirements for a good layering approach are:

Facilitate future maintenance and extension.

Be accepted by the whole team.

Define clear boundaries for each layer.

2. How to Layer – Alibaba Specification

The Alibaba coding standard defines the following layers:

Open Interface Layer : Expose Service methods as RPC or HTTP interfaces, handle gateway security and traffic control.

Terminal Display Layer : Render templates for various clients (Velocity, JS, JSP, mobile, etc.).

Web Layer : Perform access control, basic parameter validation, and simple non‑reusable business handling.

Service Layer : Implement concrete business logic.

Manager Layer : Provide generic services such as third‑party integration, caching, middleware handling, and combine multiple DAOs.

DAO Layer : Interact with databases (MySQL, Oracle, HBase) for data access.

3. Optimized Layering

Based on practical experience (using Thrift RPC), an additional layer similar to Controller is introduced:

Controller/TService : Light business logic, parameter validation, and exception handling; should remain thin to allow easy interface replacement.

Service : Core business logic; each controller method should map to a distinct service to avoid duplicated orchestration when adding new entry points.

Manager : Reusable logic such as cache, MQ, or composite operations; may handle data conversion for HTTP or RPC managers.

DAO : Database access, limited to being called only by its corresponding Service.

4. Domain Model Conversion

Alibaba’s guidelines define several domain models:

DO (Data Object): Directly maps to database tables.

DTO (Data Transfer Object): Used for data exchange between Service/Manager and external callers.

BO (Business Object): Encapsulates business logic output from Service.

AO (Application Object): Near‑presentation layer, low reuse.

VO (View Object): Passed to view/template engines.

Query: Encapsulates query parameters; avoid using generic Maps for more than two parameters.

Excessive conversion between these models can lead to multiple transformations per request, reducing efficiency.

5. Summary

Proper application layering is crucial for code reuse, clear responsibilities, and maintainability. While exact conventions may vary across teams, the goal should always be to keep each layer’s duties well defined and to simplify future maintenance.

backend developmentlayered architecturedaodomain modelAlibaba standardsService Layer
Big Data Technology Architecture
Written by

Big Data Technology Architecture

Exploring Open Source Big Data and AI Technologies

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.