Quality time with partial classes and ASP.NET
A couple of weeks ago I was rambling about code-behind and Whidbey. The reason for the rambling was that I was starting to think about how I'd build the next version of POP Forums.
Honestly, my goal in the last version was to build a class library that did the heavy lifting, and if you didn't like the UI, you were free to do whatever you wanted with it. I think that attitude came from the fact that users of my sites like a nice clean, light-weight, easy to use forum, even though the various PHP heavyweights are feature heavy. As is the case with many apps, sometimes there are more features than you really need, but that's a topic for another day. The last UI that I did is reasonably featured, but in my own projects I rarely use half of it.
That discussion had a lot of interesting comments, and it led to other discussions in other blogs and forums. Jerry Pisk made the interesting comment that all of this dreaming and evangelism about separate code and UI in the current version of ASP.NET is puppy cock (OK, that's not what he called it, but that was the tone). I tend to agree with him. I mean, you've got all those references in your old school code-behind to the controls on the page. Like any other page is every going to inherit that class!
The thing I really overlooked at the time was partial classes. After playing for a bit, it's pretty clear to me that with the UI I will provide (keeping in mind that I'm more worried about the core class library), that using partial classes is a pretty good idea as the new “code-behind” (or “code-beside” or whatever the hell it's called in the end). I know that a lot of die hard application developers aren't fond of this model, but just as it's hard for a script monkey to go OOP, it's hard for those of us in the “enterprise” (please show your membership card ;)) to look at what's most practical.
My audience is still going to be the casual coder that runs a site on underwater basket weaving. If they want to tweak the forum and mess with it, then this partial class model is perfect for that. For the really hard-core, you can always dig into the core classes to alter the way they operate.
That leads me to my next decisions regarding the use of data. Do I use ObjectSpaces? Do I create data objects that can be used declaratively? Lots of choices.
You know you're losing your hacker mentality from long-term exposure to the “enterprise” when you start thinking about doing design documents for your little hobby projects like this. That's yet another topic for another day!