Web Software Architecture Principles

Source: Internet
Author: User
Tags constant html page lowercase root directory advantage
Web

Web Software Architecture Principles

First, the directory structure is clear, should not be too deep, complex, the path is best with relative address
Second, the naming appropriate
Third, constant variable content, interface to make the template better
Four, the common public Information unified storage
Five, include files can not be embedded more
Six, the directory can not store too many content files
Seven, the data structure should design reasonable
Data validation should be on the server side
Nine, connect the database near the late, disconnected close to early
Ten, use session and cookie as little as possible

Detailed Description:

(i) The directory structure is clear, not too deep, complex, the best way to use relative address
A what kind of directory to put what kind of content, so easy to manage, so that the directory structure of the Web program, clear, a look at a folder to know what kind of functional modules and content. If you just store it for a long time, you'll never know what a catalog is for. For example: The most frequently used executable file should be stored in the root directory (the project root), which is primarily for understanding its role, but also for less typing of address characters in the program. Program used in the image of the unified storage in the root directory in the images directory, if the project is larger, more branches, can be in its directory to establish a program related to the directory name, storage related picture content. The program's configuration file is placed in the Include directory with the number of commonly used common letter categories. The function class library file name extension that is stored in this directory is named:. PHP is not named as the extension of. inc.ini files, mainly to prevent such files for users to download, or check their source code content, so that its call easy to express. The template file should be stored in the templates directory under the root directory, with the extension. html, and if the project is larger and more classified, the template files can be categorized in the lower polar directory. Temporary files are stored in the root TMP directory, which is usually set up to be readable and writable by anyone. Using relative addresses is primarily convenient for program porting.

(ii) naming appropriate
A The best name is what the program uses to make the name. If a word is to be described in lowercase words to name, to use more than one word to represent, but also in lowercase words between the underlined connection. Note that the name must not be too long, so inconvenient, although can express more clearly, but typing difficult to hit AH. Function names can also be the same in programs. Not good above also has, that is every name has to take time to think of a more appropriate name, it is for us in the English water evaluation of poor people is not an easy thing ah. (Miserable, haha!) )

(iii) Constant variable content, interface to make the template better
A) constant variable content, interface use template better, this is because when I feel a certain day not the page is not beautiful fashion, I would like to replace the newer and better interface, this time to use. If you are in the traditional production of HTML page content in the process of processing input, it is more cumbersome to change the program must not, this may be a big inconvenience in the event of a change error, this is not very good. (The program has a long period of time did not maintain, suddenly to change, for a while it is inevitable that there is no change in the wrong case). If you use a template you do not need to change the program, just change the template file on the line. Okay, so I said the benefits of my template, as if the traditional approach does not have a little advantage yes, like a penny is not worth it, is not, the template also has its bad place, now I also say how it is bad. The traditional approach is to embed HTML code in a Web program, which has the advantage of executing faster than using a template because it can output directly without any processing, and the template is different. Template to open the Read template file to a string variable can be an array of string variables, this is time, right? It takes time to replace a template variable in a template with a string manipulation function? The replacement completes before it can enter the output. What do you think of the traditional practice and the use of template practice? (I personally think that if you are developing a large number of Web sites, choose the traditional approach is a good choice, I said is relatively not absolute, if the number of visits can not be used in scripting language to write, it has to use Cgi+socket+demon. Don't say, say far, haha)



Related Article

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.