I first saw Microsoft ASP.NET in action in 2004, when it was tentatively named ASP+. At that time, building a Web application on the Microsoft platform was a matter of assembling a bunch of Active Server Pages (ASP). In a typical ASP page, you find HTML literals interspersed with code blocks. In code blocks, script code (mostly VBScript) is used to incorporate data generated by COM objects, such as components from the ActiveX Data Objects (ADO) framework. Undoubtedly, the introduction of ASP.NET in the late 1990s was a big step forward, as it represented a smart way to automate the production of HTML displayed in a client's browser. ASP.NET simplified a number of everyday tasks and, more importantly, enabled developers to work at a higher level of abstraction.This allowed them to focus more on the core functions of the Web application rather than on common tasks around Web page design. Based on server controls, ASP.NET allows developers to build real-world Web sites and applications with minimal HTML and JavaScript skills. The whole point of ASP.NET is productivity, achieved through powerful tools integrated in the runtime as well as the provision of development facilities, such as server controls, user controls, postback events, viewstate, forms authentication, and intrinsic objects. The model behind ASP.NET is called Web Forms and it was clearly inspired by the desktop Windows Forms model (in turn deeply inspired by the Visual Basic Rapid Application Development philosophy). So why did Microsoft release "another" ASP.NET framework, called ASP.NET MVC?
Benefits of ASP.NET Web Forms
As noted, ASP.NET Web Forms is stable and mature, and it is supported by heaps of third party controls and tools. One of the keys to the rapid adoption of ASP.NET is certainly the point-and-click metaphor taken from Windows desktop development. With Web Forms, Microsoft basically extended the Visual Basic programming model to the Web. Desktop development, however, is stateful whereas the Web is inherently stateless. So the Web Forms model essentially abstracted a number of features to provide a simulated stateful model for Web developers. As a result, you didn't have to be a Web expert with a lot of HTML and JavaScript knowledge to write effective Web applications. To simulate stateful programming over the Web, ASP.NET Web Forms introduced features such as viewstate, postbacks, and an overall event-driven paradigm.For example, the developer can, say, double-click on a button to automatically generate a stub of code that will handle the user's clicking to the server. To get started writing an ASP.NET Web application, you just need to know the basics of .NET development, the programming interface of some components, like server controls. Server controls that generate HTML programmatically, and the runtime pipeline, contribute significantly to a fast development cycle. At the end of the day, key features of ASP.NET Web Forms are just the componentization of some ASP best practices. For example, postback, auto-population of input fields, authentication and authorization before page rendering, server controls, and compilation of the page, are not features devised and created from scratch for ASP.NET Web Forms. All of them evolved from ASP best practices. Ten years ago, ASP developers (including myself) were looking for exactly the set of features that ASP.NET Web Forms ended up providing. Furthermore, ASP.NET Web Forms generally exceeded our expectations by providing a full abstraction layer atop the whole Web stack: JavaScript, CSS, HTML. To write an ASP page, you did need to know quite a bit about the Web and script languages. To write an ASP.NET page, in contrast, you need to know primarily about .NET and its compiled languages. Productivity and rapid development of data-driven, line-of-business applications have been the selling points of ASP.NET Web Forms. Until now, that is.
Drawbacks of ASP.NET MVC
ASP.NET MVC brings to the table a clean design with a neat separation of concerns, a leaner run-time stack, full control over HTML, an unparalleled level of extensibility, and a working environment that enables, not penalizes, test-driven development (TDD). Is ASP.NET MVC, therefore, a paradise for Web developers? Just like with Web Forms, what some perceive as a clear strength of ASP.NET MVC, others may see as a weakness. For example, full control over HTML, JavaScript, and CSS, ASP.NET MVC means that you enter the Web elements manually. Much of this pain can be mitigated, however, with some of the more recent JavaScript libraries and even different view engine. In general, though, there's no sort of component model to help you with the generation of HTML, as there is in the Web Forms approach. Currently, HTML helpers and user controls are the only tools you can leverage to write HTML more quickly. As a result, , some ASP.NET developers may see ASP.NET MVC as taking a step backward in terms of usability and productivity. Another point to be made, regarding the impact of ASP.NET MVC on everyday development, is that it requires some upfront familiarity with the MVC pattern. You need to know how controllers and views work together in the ASP.NET implementation. In other words, ASP.NET MVC is not something you can easily learn by experimenting. In my experience, this may be the source of decreased productivity for the average Web Forms developer.
No comments:
Post a Comment