Thursday, March 22, 2007

For some reason, when I'm typing (and especially when I'm coding) I often conciously attempt to capitalize numbers under certain conditions.  For some reason, my brain thinks that there's a difference.  For instance, if I was typing HttpV4Implementation, I would probably end up with HttpV$Implementation because if there had been a letter there instead of a number, I would have capitalized it.  Does anyone else have this problem?  It's really frustrating because I often retype it several times making the same mistake each time before finally realizing what the problem is.

I think this may be caused by my handwriting style, which seems to be typical of engineers, where all letters are in captial form, but differ in size to indicate capitalization.  I've seen this referred to as "smallcaps".  Oddly enough, I didn't pick this up in college as an engineer.  I decided to start writing that way in junior high after noticing how cool my granddad's handwriting was.

posted on Thursday, March 22, 2007 10:13:48 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
 Tuesday, March 20, 2007

I've been toying with Orcas extension methods recently, and I came across a situation that could be problematic.  The problem involves value types.  Generally, the advice to people is to always make value types immutable.  That is, once a type is constructed, it's state cannot be changed. There are a number of reasons behind this, and now there's one more.

Extension methods allow you to make a static method look like an instance method on another class via the "this" keyword on the first parameter.  The compiler will then use that method if it is in scope when resolving methods in code. So, the first parameter to the method behaves roughly like the "this" pointer.  However, there is a subtle difference when extending value types in this way.

In a regular instance method, the "this" parameter is passed by reference, even for a value type. (In IL, you load an address onto the stack rather than the instance)  This allows you to change the state of the object within the method.  However, for extension methods, the first parameter is passed by value.

So, if you attempt to make changes to the state of a value type in an extension method on that type, the changes won't be reflected after the method completes.

Like most value type problems, this is because you've made changes to a copy of your instance rather than the "original".  So, keep you value types immutable, or be aware of all the various gotchas of mutable value types.

posted on Tuesday, March 20, 2007 4:22:25 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
 Monday, March 12, 2007

Jeff and Bethany brought Micah down and stayed the night with us Friday night.  It was really fun.  In my opinion, Micah did awesome for his first trip away from home.  We watched The Bourne Supremacy on HD-DVD.  We wanted to watch The Rundown, but I couldn't find it on HD-DVD.

After the movie, we fired up the Wii, and played Wii Sports.  Jeff and I played boxing for the first time, and we are still sore from it.  It was an unbelievable workout.

posted on Monday, March 12, 2007 9:47:37 AM (Pacific Standard Time, UTC-08:00)  #    Comments [3]

Many people are lamenting loosing an hour of sleep last night.  I, for one, welcome our new GMT offset.  When you're in school, loosing that hour is rough, but in the last several years, I've really grown to appreciate extra light in the evening.  You can get so much stuff done when it's light out (particularly stuff that needs doing outside).  As a parent, I've also become less annoyed at loosing sleep.  Just 1 hour?  Big deal.

Now that I live in Washington, extra light in the evening is far more desirable.  During the shortest days of the year, it was getting dark at 4:30!  Lots of people prepared me for the gray, rainy days of winter here, and that really hasn't bothered me.  However, I wasn't prepared for the short days of winter. I really hope they make daylight savings last all year.  But, I'll be happy with the few extra weeks we get now.  Last night, it was still plenty light at 7pm (I don't recall when exactly it got dark).  Now, I can't wait until the summer when it's still light out at 10pm.

posted on Monday, March 12, 2007 8:32:45 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
 Monday, March 05, 2007

One of the great benefits of moving to Washington has been that we've been able to hang out with my college buddy Jeff Flint and his wife Bethany.  In fact they are coming down for a bit this weekend.  Today is his birthday, so Happy Birthday, Jeff!

Here he is posing for a recent spread in the REI catalog.

posted on Monday, March 05, 2007 12:29:10 PM (Pacific Standard Time, UTC-08:00)  #    Comments [1]
 Tuesday, February 27, 2007

I saw the following web address on a flyer in the breakroom: www.tacomaopera.com.  My brain didn't split it up as "Tacoma Opera", it read it as "Taco Maopera".  Rats, and I was thinking it was another Mexican food place to check off as being not good.

posted on Tuesday, February 27, 2007 3:32:26 PM (Pacific Standard Time, UTC-08:00)  #    Comments [1]
 Wednesday, February 21, 2007

A quickie here. I had written some code in javascript to simplify testing of a fairly dense, multi-dimensional feature area.  I could define the dimensions I wanted to test declaratively in a more or less JSON fashion and then bang them together via some enumerable-like extensions that I had written.  Viola, full test matrix implemented.

Unfortunately, I learned that I would be unable to take a dependency on the scripting host at run-time.  Too bad I had already invested the time in the solution, and I would now have to code the matrix myself.  But wait, this is a dynamic language I'm dealing with!  So, in a short time, I did some object substitution, and now my javascript is a precompiler that emits C# and other support files that I then compile to do the same thing.

Nikhil has a more general tool that goes the other way.  It compiles C# into javascript for use in AJAX apps.  While this is a handy way for people unfamiliar with the power of dynamic languages to jump into the AJAX world, I'm wondering if it's really a good idea in the long term.  On the one hand, reducing the number of language dependencies in a project is good for maintainability, but choosing the less-flexible one seems like the wrong choice.  Of course javascript has no formal set of class libraries, so that's a limitation.  Hmmm.  I'll have to think about this some more.

posted on Wednesday, February 21, 2007 10:05:09 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
 Tuesday, February 20, 2007

All .NET developers, proceed immediately to Lutz Roeder's site (remember, I have his office shelves) and download Reflector 5.0.  It has a ton of new features.  So many that I won't attempt to list them here.

This tool was a part of my programmer's arsenal before I came to MS, and I still use it daily to spelunk around the managed code in the CLR and framework, even though I have access to the source code. It is an incredibly powerful tool that combines static analysis, documentation, disassembly (into multiple languages), search, etc.

If you're looking to get into C# for the first time (and I know several of you are), it is helpful to be able to look at your code as if it has been written in C#, or look at code that was written in C# in another language so you can see how C#'s constructs are saving you time (over some languages).

Ok, I said I wasn't going to list features, but I know some of you won't click through the powerpoint deck.  The new version can fold anonymous delegates, and even C# 3.0 lambdas and LINQ queries back into their original syntax.  Of course it's configurable, so you can still see what the compiler's doing for you.  It also adds proper Vista support.  It also adds support for code:// urls (Ex. code://mscorlib/System.Object). Oh, and the Add-Ins are hosted on CodePlex now.  Tons more stuff.  Get it now. No excuses.

posted on Tuesday, February 20, 2007 8:39:40 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
 Monday, February 19, 2007

I'll take a break from the technical posts for a moment.  Friday night, I helped out with a youth lock-in up at the church.  It was just like old times (except no spitting ice down the stairs).

The youth group at our church is decidedly smaller than at our church in Austin.  But, it makes sense because the actual church is much smaller than our church in Austin.  There were about 8 guys there (the girls were elsewhere).  We pretty much played video games all night.  We had 2 Wii's, a PS2, an XBox and an XBox360.  We also played some (outdoor) capture the flag.  It was a variant that I hadn't played before in Texas, and I didn't really understand it.

The highlight of the night was linking the xbox and the 360 and playing some 4 vs. 4 Halo 2.  I don't like to brag, but I did pretty well.  Mainly it was fun because they were trash-talking pretty bad about how they were going to beat me.  One game in particular (4v4 Team Slayer on Beaver Creek) I lead my team to victory with 35 kills and only 3 deaths.

It was cool to connect with the guys in that way. They are having a "ski day" on Wednesday, and I'm bummed that I have to work.  The whole concept of a day trip for snow skiing is completely foreign and bizarre to me.

posted on Monday, February 19, 2007 11:43:11 AM (Pacific Standard Time, UTC-08:00)  #    Comments [3]