Asp.net Label vs Literal

It looks like I have fallen victim to an asp.net no-no.

I have always used a label in my forms when I want to have some text that is updated by the code behind.  Turns out that I should probably be using literals.

Even more, I didn’t even realize that the label object allows you to specify a text element that will gain focus when the label is clicked.  Nice.

Simulating HttpContext

Update: Phil Haack has updated his HttpContext Simulator with some new goodies.

Here is an article by Haacked showing how one can create a test friendly httpcontext.

I modified his example some and started using it in some tests; works very nice!

Here is another implementation based on Haack’s example that is supposed to also work with session.

I almost NEVER use session if I can avoid it, but still this could come in handy.

Null Object Refactoring

Here is a nice article on Null Object Refactoring, a process where you create a null representation of an object for use when you want to treat the object as null, rather than passing around a truely null object.

This is one of Fowlers refactoring suggestions from his book: Refactoring: Improving the Design of Existing Code and on his site: http://www.refactoring.com/catalog/introduceNullObject.html