first, The Web project is the simplest composition
1. What is a Web project
the So-called Web project is a visualization program which can be accessed through the network , which can render the data information in response to the User's interaction with the browser as the display carrier .
As shown in the Following:
The PC side of the figure is the so-called browser side in the b/s architecture, which is used to render the Web page, the user enters the URL in the browser, and after the DNS resolution is completed, the HTTP request is sent to the server side of the resolved IP address. After the server receives the request, according to the deployment of the Information Services Manager (IIS), the corresponding page is returned and the required files are loaded, and the error page is returned if the request parameter is incorrect or no access Permission.
The user in the Web page mouse click, text input and other input operations, generally according to the web page of the element definition or JavaScript script to respond to, if the service side to provide data processing, such as special processing, through the Ajax way to communicate with the server side and data Transmission.
Data sources use a database, and local files such as. xls,. txt, and so on, each corresponding to different access methods. Depending on the business logic requirements, decide whether to use and use what data source.
These are the most basic components of a web Project.
2. Involving knowledge structures
second, from the angle of the iteration to see why layered
1. iteration
We develop a product that, if not too complex, uses a waterfall model, simply by defining the requirements, then building the framework, then writing the code, then testing, and finally releasing a product. But this way has obvious shortcomings, if we do not judge the User's needs is very accurate, when you bring the product to the customer to see, the customer will often be surprised, this is what I want?
At this time the cost of modification and risk is often huge, so in order to avoid this risk as much as possible, reduce the cost of modification, in the project practice will often use an iterative way to complete the Development. That is, in the development process to continuously communicate with the customer feedback, so as to obtain the customer to the completed part of the revised opinion, with less time and manpower cost correction, while continuing to carry out the unfinished development. This is what we call iterative development, through constant feedback and constant revisions to meet customer Requirements.
PS: Another common situation is the customer's part of the demand for changes in the middle or too late to determine, at this time also need to develop staff to face modification, rework psychological Preparation.
2. layering
Microsoft's recommended layered structure is generally divided into three tiers, from bottom to top: the data access layer, the business logic layer (or also called the domain layer), the presentation layer.
- Data access Layer: mainly for Non-raw data (database or text files, such as the form of data storage) operations layer, rather than the original data, that is, the operation of the data, rather than the database, specifically for the business logic layer or presentation layer to provide data services.
- Business logic layer: mainly for the specific problem of operation, can also be understood as the operation of the data layer, the data business logic processing, if the data layer is a building block, the logic layer is the building of these blocks.
- Presentation Layer: in the case of aspx, a page that provides data presentation and interaction, and if the logical layer is quite powerful and complete, the logic layer can provide services perfectly, regardless of how the presentation layer is defined and Changed.
3. Iterative Requirements for tiering
The most essential difference between object-oriented programming and object-oriented programming is probably the encapsulation and reference in object-oriented Programming. This greatly reduces the amount of code and provides the basis for features such as Inheritance. however, in the development of many beginners, often forget the definition of the Class-a high degree of abstraction of things with common characteristics, so the definition of confusion, the complexity of reference errors, code redundancy and so On. For example, a beginner may define a sqlconnection, Configure the connection string once, and then define SqlCommand in each code snippet that needs to execute the SQL statement, so that there are several similar pieces of code in a project, resulting in code redundancy, and if the database connection string needs to be modified, You need to modify multiple places continuously.
In fact, a better way to deal with the database is all the operations are encapsulated in a class, in order to spread more online SqlHelper.cs as an example, the internal definition of add, delete, check, change and other access to the database method, the construction method defined SqlConnection and execute its open method, The database connection string is defined in the config file so that in each code snippet that needs to execute the SQL statement, only one SqlHelper class is instantiated, and then the corresponding access method is called, and the connection string needs to be modified, just change the definition of the string in the config File. The rest of the code does not need to be adjusted.
thus, in the code implementation process, the database access, modify the related methods, in one project, the method of processing data by business logic in another project, the presentation layer contains only the interaction and the definition of data presentation, in order to minimize the additional workload of a layer of modification, It not only reduces the risk cost of the demand change, but also follows the software design idea of "low coupling and high cohesion".
That is, from an iterative perspective, the purpose of a layered architecture should be taken-reducing the cost of Modification.
Architecture Concepts for The. NET WEB Starter Series