<pedrocorreia.net ⁄>
 

<ASP.NET Postbacks and Viewstate Considered Harmful ⁄ >




clicks: 4413 4413 2006-08-24 2006-08-24 goto programacao myNews programacao  Bookmark This Bookmark This


I recently had to work on an application that I hadn't looked at for several months. In the intervening time, I had forgotten how much I hate ASP.NET Postbacks and Viewstate.

Like all technologies worth using, it's possible to do really evil things with ASP.NET, but to my mind it actually makes it more likely that such evil things will happen even in the hands of an experienced developer.

Much of this comes from the lack of a Page Master system in ASP.NET 1.1 (now added in 2.0), but also the idea that working with code that abstracts HTML is easier than working with HTML itself. That's right, ASP.NET is the mother of all leaky abstractions.

For starters, it has an extremely large API (System.Web and its related namespaces contain 1000s of classes, Interfaces and Enumerations) that attempts to abstract away an HTML developer's job. In my experience, this attempt is a failure. If you're writing an in-house time-tracking application in a small company, the built-in controls are probably ideal. For a web agency (like us) that is very precise about accessibility, standards compliance and beautiful design, these controls simply aren't good enough, and arguably they never could be.

What I do like is the hosting APIs, the HTTP pipeline, the codebehind model and data binding. We have written our own Repeater-like controls (with the help of Nikhil Kothari's excellent book Developing ASP.NET Server Controls and Components) that bind to a data source declaratively, and provide strongly-typed access to the results. We don't use DataTable or DataSet binding except in a very very few circumstances because you've no control over the data structure. We use IDataReader and strongly-typed entities and collections instead.

Onto Viewstate! 90% of developers we interview don't know how Viewstate works, even though they are strong on many other aspects of .NET, web development and programming generally. Very few can describe the process by which a client-side action such as clicking a link generated by LinkButton results in a server-side event being raised. Even fewer understand the intricacies of the Page life-cycle (the difference between a constructor on a Page-derived class, OnInit, OnLoad etc). What this does is raise the quality bar required to develop good ASP.NET applications. Note I said good applications. By this I mean applications that can be maintained by someone other than the original coder.



este é só um excerto do artigo, para aceder ao artigo completo, clique no link em baixo:
this is just a small excerpt from the article, to access the full article please click in the link below:

http://staff.interesource.com/james/aug06/viewstate_postbacks_harmful....




Subscribe News RSS  Subscribe News Updates by E-mail





myNews <myNews show="rand" cat="programacao" ⁄>

RouterJs: easy routing for your ajax Web applications new ...

RouterJs is a simple router for your ajax web apps. It's build upon History.js which means that Rout (...)

clicks: 16701 16701 2012-05-14 2012-05-14 goto url (new window) haithembelhaj.g... goto myNews programacao


Backbone computed properties new ...

This gist shows one way to implement read- and write-enabled computed properties on a Backbone Model (...)

clicks: 16531 16531 2012-05-13 2012-05-13 goto url (new window) https://gist.gi... goto myNews programacao


Android Query new ...

Android-Query (AQuery) is a light-weight library for doing asynchronous tasks and manipulating UI el (...)

clicks: 16733 16733 2012-05-12 2012-05-12 goto url (new window) code.google.com... goto myNews programacao


Create Instagram Filters With PHP new ...

In this tutorial, I'll demonstrate how to create vintage (just like Instagram does) photos with PHP (...)

clicks: 16297 16297 2012-05-12 2012-05-12 goto url (new window) net.tutsplus.co... goto myNews programacao


HTML5 jQuery Paint Plugin new ...

Websanova Paint is a HTML5 canvas based jQuery plugin. It allows you to free paint on a canvas area (...)

clicks: 27376 27376 2012-05-12 2012-05-12 goto url (new window) websanova.com/t... goto myNews programacao


Real-time Applications With Node.js and Socket.IO new ...

Hey everyone! Sorry about the long pause since the last blog post, life has been quite hectic for th (...)

clicks: 16666 16666 2012-05-11 2012-05-11 goto url (new window) codingcookies.c... goto myNews programacao


Sass vs. LESS vs. Stylus: Preprocessor Shootout new ...

CSS3 preprocessors are languages written for the sole purpose of adding cool, inventive features to (...)

clicks: 15957 15957 2012-05-11 2012-05-11 goto url (new window) net.tutsplus.co... goto myNews programacao


15 Handpicked jQuery Drop Down Menus Tutorials new ...

Here we are presenting another brilliant collection of 15 jQuery navigation menu that you can downlo (...)

clicks: 15672 15672 2012-05-10 2012-05-10 goto url (new window) smashingapps.co... goto myNews programacao