Summary of Distributed Project specification

Source: Internet
Author: User

The remote invoke Project specification summary is roughly the same as the schema, but basically the same, and some projects that use MAVEN management only need to build two projects.

remote invocation of distributed core ideas: interface-oriented programming, code-cutting, load balancing, server caching.

The following specifications are designed to facilitate the realization of their core spirit.

Data entities follow the ORM mapping mechanism.

Entity attribute naming format Mouldname; Without underlining, you can use the tools generator Eclipse plug-in to automate generating entity classes and mapping Mapper.xml files


Remote Call layered format


Client Engineering

Front end: JS, image, CSS, Html separate, using the connection form. Plug-in standalone.

Action layer: name ends with--action suffix.

Other tool layers:

Interface Engineering:

Remote Call interface: End with--remote suffix.

Database entity layer:

Additional data entities: You can inherit database entities by adding fields that are not included in the database.

Other tool layers:

Returns the data layer: encapsulates the return data, including the return code and other information.

Remote Service Engineering:

Remote interface Implementation layer: Implements interface in the interface engineering. and invoke the business logic layer. End with a--remoteimpl suffix.

Business Logic layer: Divide into interface layer, and implement layer, end with--service and--serviceimpl suffix. Process business logic and transactions.

Database layer: Divided into interface layer, and implementation layer, ending with--dao suffix

Other tool layers:

Database mapping file namespace on: can prevent naming conflicts

Usestatementnamespaces= "true" under setting in Sqlmapconfig.xml

<sqlmap namespace= "User" in each mapping file >

Call This.client_r.queryForList ("Getuserbyid");

The use of this keyword can improve the readability of the code.

Exception try---the difference between catch and throw.

Where the exception occurs is where the try---catch capture, which can better pinpoint the exact location of the exception. Also for better implementation of post-log processing.

Throw throws the exception upwards and throws it to the upper layer.

Named entity layers are generally used in English nouns. Service layer, control and forwarding layer and data layer generally use driven words, in English words splicing, can not use shorthand, the name to achieve the ability to express the function, it is possible to do 0 comments written.

The service layer writes a table that corresponds to a single entity corresponding to a database access layer, corresponding to a business logic layer. Business logic needs to operate on multiple tables,

Need to see the result of the final return is that the entity is the main, where the classification, here is to achieve the relevance of the Code. Hope to see the "refactoring-improve the existing code" this book, the above case operation, it is very helpful.

code block sequential format in a class:

private static final

Private Hompushremote

private int userId;

Get,set method

Functional methods

Debug print, Avoid sysout. The use of log printing, you can distinguish between various types of information printing, but also for the convenience of post-log processing.

private static Logger log = Logger.getlogger (Homproductaction.class);

Log.debug ("");

The interface naming of the remote service layer does not have the business meaning of the client layer. To achieve the unity of the interface, in order to realize the simple interface, and interoperability.

The code is written from the business requirements to the action layer, thinking about what interfaces are needed, and going to the interface engineering to see if there is an interface for that feature, and no more creation.

A layer-by-layer, top-down drive development that reduces code redundancy. General additions and deletions to check this four features, plug-ins can be automatically generated.

The action layer differentiates the build package based on the requirements, and the same module's pages are placed in the same package, one layer at a level.

Ibatis Mapping File Structure

File Namespace configuration

Sqlmap

Common SQL statement block

Function Statement block


This article is from the "Nighthawk Soar" blog, please be sure to keep this source http://iritchie.blog.51cto.com/7031731/1668952

Summary of Distributed Project specification

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.