1. [Recommended] The upper layer depends on the lower layer by default. Arrow means direct dependent. For example: Open Interface can depend on Web Layer, it can also directly depend on Service Layer, etc.:

Application Layers - 图1

  • Open Interface: In this layer service is encapsulate to be exposed as RPC interface, or HTTP interface through Web Layer; The layer also implements gateway security control, flow control, etc.
  • View: In this layer templates of each terminal render and execute. Rendering approaches include velocity rendering, JS rendering, JSP rendering, and mobile display, etc.
  • Web Layer: This layer is mainly used to implement forward access control, basic parameter verification, or non-reusable services.
  • Service Layer: In this layer concrete business logic is implemented.
  • Manager Layer: This layer is the common business process layer, which contains the following features:
      1) Encapsulates third-party service, to preprocess return values and exceptions;
      2) The precipitation of general ability of Service Layer, such as caching solutions, middleware general processing;
      3) Interacts with the DAO layer, including composition and reuse of multiple DAO classes.
  • DAO Layer: Data access layer, data interacting with MySQL, Oracle and HBase.
  • External interface or third-party platform: This layer includes RPC open interface from other departments or companies.

2. [For Reference] Many exceptions in the DAO Layer cannot be caught by using a fine-grained exception class. The recommended way is to use catch (Exception e), and throw new DAOException(e). In these cases, there is no need to print the log because the log should have been caught and printed in Manager Layer/Service Layer.
   Logs about exception in Service Layer must be recorded with as much information about the parameters as possible to make debugging simpler.
   If Manager Layer and Service Layer are deployed in the same server, log logic should be consistent with DAO Layer. If they are deployed separately, log logic should be consistent with each other.
   In Web Layer Exceptions cannot be thrown, because it is already on the top layer and there is no way to deal with abnormal situations. If the exception is likely to cause failure when rendering the page, the page should be redirected to a friendly error page with the friendly error information.
   In Open Interface exceptions should be handled by using error code and error message.

3. [For Reference] Layers of Domain Model:

  • DO (Data Object): Corresponding to the database table structure, the data source object is transferred upward through DAO Layer.
  • DTO (Data Transfer Object): Objects which are transferred upward by Service Layer and Manager Layer.
  • BO (Business Object): Objects that encapsulate business logic, which can be outputted by Service Layer.
  • Query: Data query objects that carry query request from upper layers. Note: Prohibit the use of Map if there are more than 2 query conditions.
  • VO (View Object): Objects that are used in Display Layer, which is normally transferred from Web Layer.