Transfer from http://www.cnblogs.com/ndxsdhy/archive/2011/08/04/2127908.html
Think this article is very easy to understand,
Http://www.cnblogs.com/JeffreyZhao/archive/2007/12/22/Experience-for-Asp-dot-net-and-WebForms.html
Http://topic.csdn.net/u/20100111/14/36a773b7-8663-4694-a085-274bdd4317d9.html
About the Ox man and ox man Wuqi without Data control,
Alas, for me this kind of drag control grew up the side dishes to intercede why. Learn about. NET MVC in: Learn to slowly detach from the control.
"
First of allMVCand three-tier architecture, is not the same.
In a three-tier architecture, the DAL (data access layer), the BLL (business Logic Layer), and the Web tier perform their duties to separate responsibilities.
MVCIs Model-view-controller, strictly say that these three add up later is the three layer architecture of the web layer, that is,MVCThe web layer in the three-tier architecture is differentiated again, divided into the controller, the view, the entity three parts, the controller completes the page logic, through the entity to complete the call with the interface layer, and the C layer directly with the three layer of the BLL dialogue.
So. NETThree-layer structure, there is no action concept.
ASPMVCis a new website development architecture that Microsoft has released. In order to solve the traditionalASPIt is not designed to separate model,view and controllers in development.
In order to solve the problems of portable, maintainable and extensible, the Web site will be designed into three separate modules, the model is responsible for the database part, the view is responsible for the interface of the Web page, and the controller is responsible for interface and data interaction and business logic, This design of the site if you want to design or re-develop a module for the other modules is not affected. ButASPThe page background code is one by one corresponding to each page code, and the business logic is inevitably written in the background code associated with the view in some cases. This will not guarantee the separation of the view and controller, it is difficult to implement the site rewrite and upgrade.
And inMVCThe page code is not corresponding to the background code one by one, but is stored as controller and view two parts, completely resolved, view and controller can not be independent of the problem. This improves the process of rewriting and upgrading the site.
ButMVCAlso has its drawbacks, because server controls are no longer available in the page code, so someASPThe use of server-side controls has caused trouble, andMVCThe design of the page also brings a lot of obstacles.
ASPMVCis a new website development architecture released by Microsoft in April 2009, Http://msdn.microsoft.com/en-us/library/dd394709.a SPX, which is the traditional sense ofMVCThe idea of development was integrated intoASPDevelopment.
So let me also talk about my understanding of both.
First of all on this topic, itself is problematic, "XX structure" and "xx mode" difference? What is the difference between Chinese social system and American way of life?
The two themselves are talking about different directions and angles, and in practical applications they do have some similar characteristics, in manyBooksAlso did not explain in depth, so as to cause confusion, in order to better understand them, let's say the difference.
First n-tier structure is a software abstraction hierarchy, is a vertical segmentation of complex software, each level to complete the same type of operation, so that the various code with its completion of the mission as the basis for segmentation, in order to reduce the complexity of software and improve its maintainability. In general, the hierarchy is down-to-bottom, the underlying code is not determined by its interface (contract), the upper layer of code is not developed, the underlying code interface (contract) changes will make the upper layer of code changes together. The three-layer structure is a kind of n-layer structure, which is an application-wide n-layer structure derived from the long-time use of human, which is widely circulated and even written in textbooks as a typical software hierarchy.
MVCA pattern is a composite design pattern, a solution that can be repeatedly practiced to solve a practical problem in a particular situation. Coincidentally, he also has three things, so people have a kind of the corresponding relationship: Display layer-view; business logic layer-control; persistence layer-model. First of allMVCThere is no obvious hierarchy between the three things, there is no obvious downward dependency, instead, the view and model are often relatively independent, and control is the bridge between the two, they are more like horizontal slicing. This results in a result,MVCEach block can be tested independently, and in a three-tier structure, the upper module runs tests that provide lower-level code or piles that provide the same interface. Relatively speaking,MVCMuch more complex, but with clearer structure and lower coupling.
Other than thatMVCEach piece inside, especially the model interior, is often designed to be multi-layered. In my opinion of a goodMVCIn the structure of pattern building, control is the core, small and stable, can be provided as a core framework, there are extensibility points, but basically can be easily configured to run without any code. The view may be a set or a variety of alternative views engine, determines the software presented to the interface, the use of the main workload is the extension point and the number of different view templates as needed. Model is a business provider, which determines the functionality provided by the software, the internal may be some ordinary class or the implementation of certain interfaces of the class, in which may be different from the business color, for complex software may be divided into many layers, such as the business Logic layer, the service provider layer, the system provides layer, the data supply layer , data access layer, and so on.
I often use metaphorsMVCThe example is the kind of cassette game machine played in childhood, control is the host, generally I buy a host on the line, as long as he is not bad, he can always let me play this kind of game. The view is the TV and the game handle, the television can work independently, he regardless of input is the television signal, the DVD player signal or the game console signal, he just displays, and he decides how we see the effect is how, if I want a bigger or the color display effect, I just need to buy a corresponding TV on the line, the handle is also can be changed, to the remote pole or with vibration. The model was a game cassette, and he had to decide what game I was playing, whether it was the bucket or Super Mary, and the console and the TV maker never knew what kind of game it might run on. There may be game codes and storage units in the cassette, which are designed according to the needs of the game.
Some friends refer to the interface of the cassette slot provided by the game host, in the design, sometimes also by the control provides a set of interfaces for the model or view implementation, thus forming a dependency. In general, this design is not too big problem, but will increase the coupling between the modules, but also bring some intrusion. In order to be more perfect, you can use the interface to provide the contract, can be used configuration information (or metadata information) + reflection to provide the contract, then this class interface can be degraded to as long as CLS-compliant, that is, ordinary class, like the current computer interface widely used USB, whether it is a USB flash drive, printer, Scanners or dongles, they're all normal USB devices.
Referring to the USB has a digression, the module's pluggable design or even hot-swappable design, the system can not stop the operation of the dynamic mount or remove the module, the dynamic Mount module requires the system to automatically discover new modules and according to the self-described information automatically configured, remove the possibility of a more complex, need to " Safely Remove Hardware "features similar to this.
Many scenarios are considered when designing broadly reusable frameworks to achieve greater adaptability, and applications in general projectsMVCMode can be more casual.
The road of job search share--personal face question (i) 1/three layer and MVC difference