Javaweb Project Naming conventions

Source: Internet
Author: User

I. Structure of the project

This is not very different from other projects, I draw out the template, easier to analyze and understand:

Explain: JS mainly includes extends (the introduction of third-party JS), module (the Project module's own JS), Lib (refer to the package, which can continue to split), module contains the specific modules in JS. Common.js is the core namespace of JS.

Second, Common.js

Explain, globals as the global namespace, each module can be defined in this namespace domain (if you do not understand the name of the namespace can be self-taught, the file is written to die, do not have specific understanding).

Third, Task.js

This file is the module of my project in the task module JS (example), the module-level JS is generally a relatively independent method of the page to pull out of the method, do not recommend all pages JS are brought in.

Explain: The module-level JS mainly includes its own private properties and methods, and the external exposure of the JS properties and methods. Here we default to the internal private front all add "_", finally decide which methods and properties exposed, is through the construction method constructor to external exposure.

Four, page index.jsp

Now look at how the JSP in the page JS and module JS is how to reference it, witness decoupling and the time has come.

Explain: the page needs to introduce Common.js and task.js and initialize it so that it can access the methods and properties exposed in the task module.

Page JS recommends that all variables be sent in a variable group, which is easy to maintain.

The OnClick method of the control in the page is recommended to be uniformly bound in JS.

Summary: Through the above configuration, the biggest advantage is the frequent introduction of JS files in the project, eliminating the coupling between the different modules of the same name method and attributes will not affect each other, of course, the most important to facilitate sustainable development and maintenance, but also the enjoyment of art.

This article uses the annotation style which I used, of course can vary from person to person, my principle is:

1. Module Introduction Code main concern: module description, responsible person, related remarks, using double star annotation

/**

*

*/

2. For the division of large areas under the module, it is customary to use double-line annotations:

//==================================================

Describe:

3. For the region, the method notes, through past experience, not everyone is willing to write in detail, so I think simple and clear best, using general comments:

Code description

Author notes and other information (not limited to)

4. For some important methods in the region, or to distinguish between the delineation of the inter-community, using the star horizontal line

/**************************** Description *****************************/

Javaweb Project Naming conventions

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.