Why I think Scott Guthrie Recommends or Recommended ASP.NET Code-Beside Designs

The .NET Framework The picture at left is a picture of the .NET Framework. It’s a folder full of ‘stuff’ on your hard drive. In fact, it’s the old version of the .NET Framework (the latest release is in another folder, sitting right next to the one shown). I show this folder to remind myself of when I started living with the .NET Framework: the create date shows Monday, March 11 2002, 9:36:40 pm. So over three years is my time with the .NET Framework. (We can subtract about six months from the three years because after it was installed back in 2002 it just sat there being ignored by me.) By the way, one could argue that the 1.1 version of the .NET Framework is the ‘useable’ version of the Framework and this did not appear on my primary development machine until 4/10/2003.

Let’s confine ourselves to about two years of me actively implementing my ‘personal’ technology plan to divest from VB6/ASP, COM-based ‘linear prose’ (spaghetti) and move into the ‘abstract-morphic’ world of the .NET Framework. The technology plan in bullets:

My recent ASP.NET epiphanies finally reveal to me why ASP.NET 2.0 added or removed (based on the Beta you are fruggin with) the code-beside model to its design. But let me be clear about what I mean by “code-beside” patterns. I mean creating an ASPX page and loading it up with Web form controls and script blocks running at the server. These script blocks sit beside the controls—hence code beside… (No dependencies on partial classes here.) This is nothing new: the tutorials on asp.net have been using this pattern from the beginning. Why am I so late to the party? Because the current RTM version of Visual Studio .NET is almost entirely ignorant of this pattern. You have to work against Visual Studio .NET to build code-beside pages (which, to me, is why The ASP.NET Web Matrix Project has been so popular). Now that years of writing C# and VB.NET code under the tutelage of IntelliSense™ have gone by, I can break the fetters and drop small blocks of code directly into script blocks. I stress the word “small” because:

When you are writing ASP.NET pages that require inheritance and hundreds of lines of code you are probably on the DotNetNuke.com portal team or you are cramming code into your client that should be in another layer of your application (like a “business rules” or data access layer).

When you can redesign your code-behind ASP.NET pages such that almost all of the code resides in the Page_Load() event procedure, you are probably wasting your time (like I have been doing for at least a year) trying to define a formal namespace and class name for these pages and compiling it into a DLL. I would prefer to throw it all in ASPX files that compile dynamically and treat it like my ASP files I hate so much. The opinion here is and will be vindicated by the following:

Scott Guthrie produced a motion picture Web cast at Microsoft showing off ASP.NET in the future release of Visual Studio.

rasx()