Scott Hanselman

Whew. What a week. Rediscovering the basics.

February 06, 2004 Comment on this post [4] Posted in ASP.NET | Gaming | Tools
Sponsored By

Whew.  This is the first week in recent memory I didn't blog much.  What have I been up to? 

  • Spent Monday-Wednesday in Atlanta.  Spent our time at the Hilton in ATL. 
    • Side Note:  My laptop that died last week was replaced and slowly rebuilt.  Fortunately, all my Utils were easily available. :)  Got a lovely IBM Thinkpad, my first IBM. 
    • Side Side Note: Seriously, drink this in.  Picture this:
      I was sitting in the Hilton Lobby with my new laptop.  Wireless access available in the ENTIRE hotel.  Sitting at the  CTRL-ALT-DEL login screen, hit the sequence, and am greeted by a Cisco VPN software popup. "Would you like to log into the Domain via VPN?" Oh, hell ya.  So, wireless VPN into Corillian using Secure Certificates (We have our own Cert Server), then Login again and am authenticated (NOT a cached profile) by the Active Directory.  All the Login Scripts run (they don't when you are logged in with a cached profile, which happens when you're on the road for weeks) and I'm set. I launch Outlook using cached Exchange Mode and sync email the way it was MEANT to be synced.  Meaning: My outbox actually GOES OUT and my folders and calendars (and
      MSN Direct Watch) all sync.  (Only took 2003 versions, but OH they got it right this time).  Then I run a CVS Update via the masterful Tortoise, then checkin securely all my changes for Build 007 of the snazzy bank I'm working on.  I chat securely with my Windows Messenger that's integrated with Exchange 2003 and the SIP Server.  Exchange a few files by dragging them onto the Messenger Window.  Logout.  From a Hotel in Atlanta.  Glorious, and beats the pants off of Outlook Web Access from Kinkos.  Thanks Microsoft and Corillian IT.
  • Still hip deep in ASP.NET.  I'm still excited about ASP.NET 1.1 and the power of abstraction.  It's good that even though I've been "in the game" for over 10 years that I'm still excitable about rediscovering the basics.  Finding the level right abstraction, the best name for function, or a fantastic new function overload that makes all the pieces of a problem fall into place like that perfect Tetris Piece you've been looking for - is such a rush.  Even if it's little stupid stuff. 
  • Here's a stupid example of rediscovering the basics.  I've (and the team) have been using the HttpContext.Current.Items[] collection a bit for stowing away things that you might need later in the same Http Request.  It's a little known (more now) storage area that lasts just for this Request.  It's NOT the session object, and you don't want to put a lot of stuff in there.  But, for example, I need to do a bunch of checks for various things and hash the result.  Turned out that was useful and it was being called WAY too often, even in one call.  But it wasn't changing the call, so I wanted to stow it somewhere. So I did this:

    string retVal = HttpContext.Current.Items["SomethingICareAboutForOnlyThisCall"];
    if (Strings.IsNullOrEmpty(retVal) == true)
    {
       retVal = BuildThisComplicatedStringAndTakeSomeTime();
       HttpContext.Current.Items["SomethingICareAboutForOnlyThisCall"] = retVal;
    }
    return retVal;

    But that pattern appeared in like 5 other places.  So, I did this:

    string retVal = CacheHelper.RequestCachedItem("SomethingICareAboutForOnlyThisCall", new ItemBuilderDelegate(BuildThisComplicatedStringAndTakeSomeTime));

    (Of course the names of everything have been changed to protect the innocent.)  So, I pass into RequestCachedItem the key for the item and a Delegate to build the item in case it's not cached.  It's a common pattern for caching, and served itself well here. 
  • WARNINGS: Read Ron Jacobs Fun with Caching stuff and remember that if you don't measure, you may (and probably will) SLOW YOUR SYSTEM DOWN by arbitrarily adding caching.  In my example, I really need to know if its more expensive to make that object than it is to cache it in the Request's Item Hashtable and pass delegates around.  In my case it is, in yours it may not.  Measure twice, code once, unit test constantly. :)
  • Anyway: That silly piece of code was the least effort of my week, but it's those little joys that make stuff fun for me.  A little Factory Pattern that just makes things cleaner.  Changing if/thens to a switch. Ya, I know the underlying IL will compile the same, but the act of refactoring is cathartic.
  • C# RefactoryThis tool has been around a while, and I've been resisting using it, probably because of the $99 price.  (I'm more of a $29 guy)  But, I've given in.  It's fabulous and I can't wait until Whidbey.  Especially nice is the cyclomatic complexity (A measure of the number of linearly independent paths through a program/function/class/etc.) calculator that gives you an idea of where you might want to start your re-thinking. The Tidy Imports feature is ALMOST worth the price of admission.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
February 06, 2004 18:27
Which ThinkPad?
February 06, 2004 19:08
Love the ThinkPads. They're all I've used for years and any problems I've had (very, very few) have been easily and quickly resolved.

C# Refactory: Great tool, but I'm afraid to drop any cash on it due to the state of its forums. There are posts that have gone unanswered for weeks or months. People complaining of paying online and never getting licenses. In a rare post, the Refactory guy said their email was down for a month or something. Huh? 1) It's 2004, that doesn't happen. 2) You're a software company! Holy cow. There are too many bugs in it for me to drop that much cash if it's the final version.
February 07, 2004 1:15
y'know, if the IDEA plugin for VS takes too long I might look into a personal copy of the Refactory.
February 07, 2004 2:17
The last I heard the IDEA plugin is is supposed to be availabe for EAP by Feb. 10.

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.