Programming Microsoft ASP.NET 4 - Dino Esposito [9]
Whether you’re considering shifting to ASP.NET MVC or sticking to Web Forms, it is essential that you reconsider the design and architecture of your views and pages. The classic Page Controller pattern is getting obsolete and needs solutions to make it more testable and layered. An effective Web Forms application today needs separation of concerns, interface-based programming, and cohesive components. No framework will give you that free of charge, but with Web Forms you need a great deal of awareness and commitment.
The AJAX Revolution
Like it or not, the Web is changing, and this time it is changing for developers and architects. In the evolution of software, we first observe a spark of genius triggering an innovative process and the teaching of new tricks and new ways of doing things. In this case, it was the spark of AJAX and the need to build effective and rich user experiences. Next, developers start generalizing and abstracting things to make them reusable and easy to replicate repeatedly in a variety of scenarios. When this happens, we have a paradigm shift.
Today we are moving away from many of the ideas and pillars of Web Forms. It’s not a process that has a well-known and defined completion date yet, but nobody doubts that such a day is in our near future.
The spark of AJAX was just the realization that we can place out-of-band requests, bypass the classic browser machinery, and gain total control of the request and subsequent response. Is this just a little, geeky detail? Maybe, but this little detail triggered a huge transformational process—an entire paradigm shift—whose results will be clear and definitive only in a few years. That’s my guess, at least. Let’s briefly consider what paradigm shifts are and what they mean (and have meant) to humans throughout history.
Moving Away from Classic ASP.NET
As drastic as it might sound, the Web revolutionized the concept of an application. Now AJAX is revolutionizing the concept of a Web application. The Web will always remain separate from the desktop, but Web applications are going to enter a new age.
What’s a Paradigm Shift?
According to Wikipedia, a paradigm shift describes a change in most of the basic assumptions within the ruling theory of a science. The shift creates a break and clearly contrasts with the current ideas and approaches. A paradigm shift is a long process that begins naturally when enough significant limitations and anomalies have been found within the current state of the art in a discipline.
At this point, new ideas are tried—often ideas that were considered years before and then discarded. The community proceeds by trial and error, experimenting and trying to come to general conclusions. Inevitably, a paradigm shift puts the discipline into a state of crisis. (This is the term used by Thomas Kuhn, who coined the term paradigm shift and formalized these concepts.) The state of crisis manifests itself through a number of attempts to change, each presented as possibly definitive but that hardly work for everybody, at least in the original form.
The impact of a paradigm shift is particularly deep in areas that appear to be stable and mature. A great example of a paradigm shift is the changes in physics at the beginning of the twentieth century. Before the advent of Einstein’s theory of relativity, physics was unanimously considered to be a largely worked-out system. The theory of relativity he formulated in 1905 changed everything in the field, but it was only about three decades later that the process of redefining the fundamentals of physics was completed. For more information, pay a visit to http://en.wikipedia.org/wiki/Paradigm_shift. It’s definitely illuminating reading.
So now, how does this apply to ASP.NET and AJAX?
The AJAX Paradigm Shift
Even though we tend to date the advent of AJAX around the 2004, one of the core tools of AJAX—the XmlHttpRequest object—is much older. In the late 1990s, we already had all