Blog Stats
  • Posts - 170
  • Articles - 4
  • Comments - 54
  • Trackbacks - 7

 

More on code behind in .Net 2.0 Beta2

Fritz Onion posted more details on the way in .Net 2.0 Beta 2 an ASPX page is parsed and the code behind managed.

The good news is the fact that you don't have anymore to declare your controls in your code. I don't find this as a major features because I usually use the IDE design/html switch to let VS create the controls.
I also like to see in my code the controls name for reference. At the compilation .Net generates a temporary partial class, containing all the members declaration.

Like Paul Wilson (maybe just a bit too strong in his comments)  I also regret that they changed the code behind like it is today in v1.1. It will be very confusing, with partial classes everywhere, and also the fact that in many online examples, Microsoft push also the model of code embedded with the HTML page.

From Paul:

I agree that partial classes are going to be very useful in code-gen scenarios, so I'm not trying to moan about partial classes. I'm just very dissatisfied with the use of partial classes in ASP.NET for code-whatever-we're-calling-it.

Code-behind in v1.* works! And its very easy for anyone coming from an OO background to understand. It doesn't hide any magic from you -- it just works. Granted, it may have some issues for those tasked with building the VS designer, but designers are always difficult.

As far as I'm concerned, all the changes from code-behind are being made either to (1) make the designer easier to build or to (2) make things simpler for non-OO web developers by hiding things from them. The original code-beside model in the previews didn't hide too much, since it was a pure partial class implementation, although it also was not going to be easy for anyone working without a cool tool like VS, unlike the standard code-behind of today. But this new model is just introducing too much trickery that requires a tool or a compiler to make sense of it all -- not at all simple unless you only work in VS. True, I can do pure page inheritance and avoid this, but now you're telling me that I can't use the tool to help me -- and yet I can today -- so this is a huge step back for OO web developers.

Let's stop and think about what we're saying. We're saying that protected declarations in an abstract base class are too confusing! And I agree they are to far too many web developers -- but those are the developers that should be using a single page model anyhow! Corporate developers, as opposed to hobbiests, are the ones who should be using code-behind -- and they had better learn OO in .NET and not have us start hiding things from them and having everything magically work at either compilation time or runtime! So what I want to know is if you don't like code-behind in v1.* today, then why don't you just use the single page model? You can precompile that too, so I really don't see why precompilation keeps being the rationale for a lot of this crap. And I do not intend to remove my description of this as crap -- it was crap when it was first shown to me, it was crap when I first showed it to my team of OO developers (and I was trying to defend it then since I decided to go along with the crap), and its crap now.

 

Comments have been closed on this topic.
 

 

Copyright © Paschal L