ASP.NET MVC Framework - set points

    The first point is posed in the question “Do I need to switch to the MVC Framework and why?”

    With this article I would like to open a series of articles about the MVC Framework. Recently, I have been working very closely with him and with his insides and I have accumulated several thoughts, interesting observations and knowledge that I would like to share. If you are an ASP.NET programmer and are not familiar with or are not very familiar with the MVC Framework, then I would like to believe that my articles will help you understand this tool better. In any case, even if you know the subject very well, I think that you and I will have something to discuss in the comments on each topic raised.

    So, the first introductory note is devoted to the issue of the need to use or upgrade to the MVC Framework from the classic ASP.NET. This question is not simple and the answer that I will not repeat the template recommendations and comparisons that you can find on the Internet. On the contrary, I would like to turn the point of view so that you look at the problem from a different perspective.

    Why you do not need MVC Framework


    First, consider why you do not need the MVC Framework:

    * you do not need the MVC Framework if you think it is better than the classic ASP.NET. If you think so, then you do not know much about ASP.NET, you still have room to grow and what to study. If you think that the MVC Framework is better than ASP.NET, then you did not like ASP.NET and did not understand the whole charm of its ideology. In this case, it’s too early for you to switch to the MVC Framework. There is simply nowhere to switch to a new framework if you do not have the proper understanding and love for the basic mechanism. To study ASP.NET, understand why and how everything is arranged there. You do not need the MVC Framework;

    * You do not need the MVC Framework in order to use the MVC pattern. In fact, MVC has nothing to do with a particular library. The MVC Framework is just an implementation of a pattern that no one bothers you with creating and using yourself in classic ASP.NET. Try it, it’s not difficult. You do not need the MVC Framework, if the only reason is that it is MVC;

    * You do not need the MVC Framework if you want to get rid of viewstate. The MVC Framework is not intended to be a "get rid of viewstate." If you want to get rid of viewstate, then learn how this mechanism works. Why is it and what is it for. I assure you, a viewstate in capable hands is very useful. And large and heavy viewstate pages are the result of poor design or lack of knowledge from the developer;

    * You do not need the MVC Framework if you want to get rid of the automatic generation of identifiers. History repeats itself. Everything regarding the viewstate applies to id auto-generation for html markup elements. If you understand how and why identifiers are generated, you will no longer want to get rid of them. In addition, in ASP.NET 4.0 you have the opportunity to control generation more flexibly and this is another reason why you do not need the MVC Framework;

    * You do not need the MVC Framework if you want to “get full control over the markup“. In classic ASP.NET, the developer also has full control over the markup and the desire to get something else is a clear sign that the developer does not understand ASP.NET well. Once you understand how ASP.NET works with markup and how it processes requests, you can compare the classic model with the MVC Framework model. If you have a good idea of ​​how both of these mechanisms work, then the requirement in this paragraph will disappear by itself. You won’t need an MVC Framework for markup management;

    * You do not need the MVC Framework if you want readable URLs. The routing mechanism that allows you to represent human-readable URLs is part of ASP.NET, but not an internal part of the MVC Framework, so you can use routing and create human-readable URLs in the classic ASP.NET, MVC Framework for this.

    Hope you disagree with some of these points. This is good, maybe my theses will make you look at the question differently.

    Why do you need MVC Framework


    Consider the reasons why you need the MVC Framework:

    * you need the MVC Framework because you want to cover a significant part of the code with unit tests. This is a good reason to switch to the MVC Framework; its model assumes that any part of the framework can be tested at any stage. Whereas in classic ASP.NET, the postback callback mechanism often made writing tests difficult;

    * you need the MVC Framework if most of your code is not part of ASP.NET. Such code is client javascript and partially AJAX. When ASP.NET was laid the foundation for client optimization and very little attention was paid to client-side code, there was no AJAX or Web 2.0 concept at that time. Times have changed, the classic ASP.NET is also changing, it has many tools for supporting AJAX functionality, but still creating powerful client code remains a difficult task. If you have a large amount of code on the client side, maybe even as much as on the server side, then you need the MVC Framework, it will facilitate your work;

    * and the main and main reason why you need the MVC Framework is absolute extensibility. In this regard, the MVC Framework is really a framework that can be filled as you need. You can make the following comparison: classic ASP.NET is a picture drawn by a wizard, while the MVC Framework is a sketch, a sketch that you sketch, complete, provide you yourself. In the MVC Framework, you are able to redefine the mechanism at any stage from processing the request to sending the result.

    Switching to the MVC Framework should not be your search for getting rid of “problems”. Take a closer look at the problems and you will see that they are all solved within the framework of the classic ASP.NET model. Many people do not understand that the main strength and power, why MVC Framework should be used are not the “drawbacks” of the classic ASP.NET model, which in most cases stem from a poor understanding of the subject. The strength of the MVC Framework lies in its capabilities and potential for extensibility. The MVC Framework is the kind of constructor that you should wish for after you are fully saturated with proven tools. If you are faced with a problem when ASP.NET mechanisms are not enough for you, when you are constrained by the framework of the proposed model, which cannot be expanded or modified, then only then you really need the MVC Framework. Any other cases

    That’s all I’d like to say on the question “Do I need to switch to the MVC Framework and why?”. I hope that the point that I put in this article will interest you and make you think or look at the question from a different angle. In the next part, I will try to put an end to the question “How does the MVC Framework mechanism work?”.

    Progg it

    Also popular now: