Jeff and .NET

The .NET musings of Jeff Putz



My Sites


November 2006 - Posts

Link: The Windows Shutdown crapfest

I saw this via Frans, but it's worth linking to...

As ridiculous as it all seems, isn't it strange how you can't really generalize that this is the way things go all over the company. The Xbox team doesn't appear to roll this way, and in all of the talking with the ASP.NET team I've done in the last few years, they seem a lot more agile, and perhaps "lighter," as well.

Is there a way to count SQL transactions in an ASP.NET Request/Response cycle?

Is there a way to count SQL transactions in an ASP.NET Request/Response cycle? In other words, is there some simple bit of code you can wire into an HttpModule at starts and ends counting in the events of my choice?

The background here is that I was chatting with some people about performance testing in a fairly complex app. We've got a fair bit of caching involved, but it would be nice to know just from a ballpark standpoint how many times we call out to the database from start to finish, and output that number to trace or a log or something.

Any ideas? 

Daunting UI

I was refactoring some of my moderation logging stuff on the forthcoming v8, and was curious to see how some other forums do it. I had not looked at vBulletin in a very long time, and was excited to see that they have a demo system that launches a completely new instance of the app with a fresh database for you. Sweet. While I can't really get into PHP, I'll be the first to admit that it's one of the best forum apps out there, even if it does flirt with being too feature rich.

I had never seen the admin stuff at all. Imagine my horror when I saw how many options there were just to create a new forum! There are dozens upon dozens of fields! I absolutely could not believe it. Looking around, I found that much of their admin stuff is similarly bloated and complicated. I guess I shouldn't be that surprised, seeing as how the public side of the forum has a lot of junk in it, even if most of it is hidden in menus and such.

This is the struggle of a feature-rich application. How can you possibly organize all of this stuff in a way that's useful? A lot of people will say that feature-rich apps are inherently complex in the UI, but does it really have to be that way? Obviously that's something that was on the minds of the Office team this last go around, and it will be interesting to see how their work is received.

This is very much an area of software development that fascinates me. I think for many of us, the user interface is frequently secondary to everything else, and I think I would argue that's totally backward. I mean, it's like creating the ultimate writing surface without considering whether we'll use a ball-point pen or a hammer and chisel.

Pissed about Vista and MSDN subscription

Me and a friends were talking about how annoyed we are that Vista just hit MSDN, less than a month after our subscriptions expired. I'm sure there are a lot of people like us, who are independent developers that bought in right around the Visual Studio 2005 launch, with the implied promise of Vista in the distance. We were hosed.

I don't think they ever promised Vista would be available, but I certainly remember that it was implied.

Although, if I were really being honest, the next OS I'll pay for is going to be Leopard anyway. :) 

The developer-as-UI-designer requirement: Flexibility

After two years or so of having my thumb up my, uh, nose, and not writing any meaningful code for myself (and my damn forum app), I realized that perhaps the most important requirement isn't adhering to data API's or connecting to various frameworky things, but rather the flexibility to design UI with as little code as possible.

For example, you want to build a general purpose blogging app. It should be simple and easy to hack, and above all, it should be as simple as possible to change the way it looks. My first attempt at such an effort a year or two ago wasn't great, but I learned a lot from the experience. It's making the forum rewrite a lot easier.

There are two things that make flexible UI easier. The first thing is template-based controls. Yes, there are a great many of these already in ASP.NET. But the thing is, once you've developed your own, you start to realize just how much more you can do beyond the standard grids and repeaters (all of which do a ton, but never exactly what you want). You can start to do controls that also have their own paging templates, categorized header templates, ad templates, etc. Even more fun, you can start writing events to do neat things from code when the data is bound, like display certain images or whatever.

The other thing that's fun to do is what I call "controller" objects. With a little mark up, they do something cool to other things on the page. Maybe they turn visibility on or off to certain elements, or bind data, or even manipulate the title of the page. This isn't a new idea really, as DataSource controls, script managers and WebPart management components should be familiar to most people by now. Doing this kind of thing in a declarative manner keeps your code clean and truly lets you focus on the presentation. 

The missing FindControl() method

Most ASP.NET developers have probably used the FindControl() method before. It lives as a member of the Control class, way up in the inheritance hierarchy. Most also know that it's limited to finding only immediate child controls, unless you specify the UniqueID.  That always seemed weird when you used the method from the Page object, because you'd think it would go deeper.

But then I wondered how it was that data-bound controls were getting references to the DataSource controls. I fired up Reflector (best tool ever!) and looked under the hood to see what was going on. As it turns out, there's an internal class called System.Web.UI.WebControls.DataBoundControlHelper with a static method called FindControl(), taking the parent control and the ID you're searching for as parameters. The code looks something like this:

public static Control FindControl(Control control, string controlID)
      Control control1 = control;
      Control control2 = null;
      if (control == control.Page)
            return control.FindControl(controlID);
      while ((control2 == null) && (control1 != control.Page))
            control1 = control1.NamingContainer;
            if (control1 == null)
                  throw new HttpException(SR.GetString("DataBoundControlHelper_NoNamingContainer", new object[] { control.GetType().Name, control.ID }));
            control2 = control1.FindControl(controlID);
      return control2;

I'm left wondering why the design decision was made to not make this a public class. I found use for the very same code today when implementing a non-rendering control that manipulates other stuff on the page. 

Posted: Nov 08 2006, 07:02 PM by Jeff | with 3 comment(s)
Filed under:
Linear thread or Usenet-style?

I think the world rightfully has accepted the linear thread in discussion forums. The negative of this is that people quote entire, untrimmed, posts and that's annoying. (Of course, lazy asses did this on Usenet too, but whatever.)

Is there any lingering preference still for the Usenet-style tree of discussion? I personally always thought it sucked because it's not how human beings talk. It's like speaking to a room full of people and eventually having to work the entire room, one person at a time, and simultaneously conduct a zillion different discussions.

Digg does an almost hybrid approach to this, in that they only allow the branch to go one level in.

What do you think? 

VS2005 Web designer bug

I was refactoring my little heart out on a project when I realized I had a Hyperlink control in several places that always pointed to the same place. So I made a derived class in App_Code, added it to pages/controls in web.config (<add assembly="App_Code" namespace="Awesome.UI" tagPrefix="Awesome"/>), and replaced away. 

Well wouldn't you know it, doing this breaks the design view of the page when it has a master. You get the dreaded "Error creating control - Content1" exception. Boo.

I haven't been able to Google anything out of this. Has anyone else had the problem? 

Posted: Nov 06 2006, 04:03 PM by Jeff | with 2 comment(s)
Filed under:
More Posts