Rants, rambles, news and notes from another geek

Geek Notes 2005-07-26

My wife’s friend Becca was in town with her baby this past weekend, which was nice. Becca is the person who introduced Emily and myself. Her boy, Henry, is adorable and since he is the same age as Finn, it was fun watching them play together.

  • iBang’s Ultimate Shuffle Mix - You all know that I love my iPod Shuffle, but I’ll admit to being confused by the iTunes random selection algorithm. I went looking for a better way to make a shuffle playlist and found this. Pretty good.
  • Meh - It’s funny… there is a hand gesture that a number of us on the CAB team use to basically indicate indifference. It is hard to describe, but this word is the verbal equivalent. I tried to find an emoticon for this concept and couldn’t but I guess that “meh” isn’t that hard to write…
  • OfficeGuns - Wow. Cool. Small weapons made out of simple office supplied. Perfect for those long boring meetins we all have to deal with. The simplest one is the Double Maul, but you really should check out the Super Maul which they say is “not practical for random battles, but more of a gun for the determined assassin.” [via Boing Boing]
  • Boycott NHL Opening Day - Apparently a number of NHL fans are dissatisfied with the CBA agreement that ended the NHL lockout and are proposing that all “true” hockey fans should boycott the opening day games. [via DonXML]
  • Konfabulator 2.1 for Windows - I must have missed this somewhere along the way, but then today I saw these cool widgets on Brad Wilson’s desktop and I wanted them too. Apparently this used to cost money but now that Yahoo! owns them, it is free.

Now playing: Queens Of The Stone Age - Someone’s In The Wolf

Annoyed by Dates in RSS Feeds

I’ve wanted to complain about this before, but I didn’t. But then today I lost my Omea Reader database and had to start over with my RSS feeds.

I knew I was caught-up with my feeds as of about noon today, so after reloading my OPML file (you should always remember to keep a backup of that) and then sync-ing my feeds, I selected everything older than noon and marked them as read.

You’d think I would be done, right? No. Instead of the 26 or so posts that had come in since noon, there were more than 60 unread posts. The extra ones all had their dates set to the date when I sync-ed them.

Why? It turns out that it is caused in part by my reader (Omea Reader 2.0 RC) and in part by people not generating very good RSS.

As far as I can tell, Omea Reader doesn’t seem to grok the element (from the [Dublin Core Metadata Initiative](http://dublincore.org/)). Or if it does, the feeds in question aren't sending good date data. I'm not sure which. I suppose Omea should probably handle the Dublin Core stuff (I'm going to post to their newsgroup and ask), but my real question is _place_holder;why people use it when RSS 2.0 has elements for this purpose? FWIW, [Mark Pilgrim claims he does it to respect prior art](http://diveintomark.org/archives/2003/06/21/history_of_rss_date_formats), but personally I think that is silly. (Probably not as silly as Omea not supporting Dublin Core, but silly nonetheless.)

Sure, that part can probably be blamed on my aggregator. Surprisingly, however, there are famous people out there who don’t use either date element in their feeds. Why don’t they take the extra time to help ensure that their feeds are complete? I don’t know. The teenage girl down the street blogging about her cat has her feed set up correctly, but these gentlemen can’t get it right? It doesn’t seem likely given that I have books on my bookshelf, books in the “recommended reading” list on this blog in fact, that were written by the people I’m talking about. So do you. I guarantee it.

I know this is not really important in the grand scheme of things, but it annoys me.

I'm a Pacman Ghost

What Video Game Character Are You? I am a Pacman Ghost.I am a Pacman Ghost.

I like to hang around with friends, chatting, dancing, all that sort of thing. We don’t appreciate outsiders, and do our best to discourage others approaching us. I enjoy occasionally wandering around randomly, and often find that when I do so, I get to where I wanted to be.

What Video Game Character Are You?

Geek Notes 2005-07-18

Today is Emily’s birthday and apparently I didn’t give her enough information early enough in the day for her liking. &nbsp_place_holder;But I think she’ll enjoy her present: a trip to KC to see her old college friends sans children. I wanted to get her all the things she’s dreaming of, but this just isn’t the year for that. Next yearΓǪ

  • Assert.IsEqualGraph - Keith Brown has blogged a cool little code snippet that lets you compare two entire object graphs from your NUnit tests. With a couple of mods it should work with VS Test too. If only the authors of both frameworks had given us Assert.AreEqual( object a, object b, IComparer comparer ) this kind of thing would be even easer.
  • Peanut Butter and Wiki - What a great concept. Need a little wiki for your project? Want it to be private and password protected? Visit this site and you can be up and running in 30 seconds. [via Boing Boing]
  • Would you buy a camera from this store?The Truth Behind Online Camera Dealers - HmmmΓǪ Would you buy a camera from the outfit in this picture? Yeah, me neither. Don Wise has taken photos of many of the brick-and-mortar storefronts for dozens of online camera stores. Buyer beware! [via Boing Boing]
  • iTunes Music Store Weirdness - Hmmm. I wonder why the iTunes music store would require you to deauthorize your computer before you upgrade your hardware. That is as dumb as Windows making you reauthorize your Windows for the same kind of thing. Dumb dumb dumb. Now if only I could get MSN Music tunes on my iPod, all would be well in the world.
  • The Joy of Netsh - I knew there had to be a command line utility for things like the new firewall settings. Michael Howard shows some cool things you can do with this little tool. From looking at the usage output (“netsh /?”) there are a lot more things it can do too.

Fun With Ruby

A few weeks ago Brad Wilson and I were invited to come down to Portland to speak and hang out at the Portland Code Camp&nbsp_place_holder;(July 23 & 24). We pitched a few ideas to them including EntLib, CAB, Unit Testing/TDD, etc. All the usual suspects.

But Brad and I also thought it would be fun to talk about Ruby and/or Rails. If you’ve read this blog much, you know I’ve been in love with Ruby for a long time now (longer than I’ve been an MS employee), so this shouldn’t be a surprise.

Anyway, it turns out I can’t go, which is a huge bummer. But Brad is going and he’s giving&nbsp_place_holder;one talk introducing Ruby and one on CAB. Should be fun. (BTW, if you live in the Northwest, you should go. I would if I could, but I can’t.)

Anyway, today, Brad was asked by the organizers to translate this C# code into Ruby (for the T-Shirts or something like that):

using System;

namespace Community
{
 class CodeCamp
 {
   private string city;
   private string version;

   public CodeCamp ( string city, string version )
   { this.city = city; this.version = version; }

   public override string ToString()
   { return string.Format( "{0} Code Camp v{1}",   
     city, version ); }
 }

 class ConsoleApp
 {
   [STAThread]
   static void Main(string[] args)
   {
     CodeCamp pdx = new CodeCamp("Portland", "1.0");
     Console.WriteLine( pdx );
   }
 }
}

Brad was nice enough to cc me on his answer, which was this:

module Community
 class CodeCamp
   def initialize(city, version)
     @city = city
     @version = version
   end

   def to_s
     "#{@city} Code Camp v#{@version}"
   end
 end
end

puts Community::CodeCamp.new("Portland", "1.0")

Of course, Brad’s answer is the obvious direct port of the provided C# code, but I’m not sure it is the “Ruby Way”…

My first answer was this:

puts "Portland Code Camp v1.0"

But I decided that probably wasn’t what they were looking for. I am reminded of the time I demoed Ruby to Ward Cunningham and he said, “Well I see that Hello World is the right number of lines,” but I digress…

Perhaps something that shows off Ruby method redefinition would be better?

class Float
  alias old_to_s to_s

  def to_s
    return "Portland Code Camp v#{old_to_s}"
  end
end

puts 1.0

I kinda like that one, but I don’t like that the string “Portland” is embedded in my Float class. No. In everyone’s Float class. Cool? Yes. The right answer? Probably not.

After playing around with some much nastier ideas, I decided that I wanted my puts line to look something like this instead:

"Portland".codeCamp(1.0)
"San Francisco".codeCamp(1.5)
"Boston".codeCamp(2.0)

And, of course, writing this in Ruby was really easy:

class String
  def codeCamp(version)
    puts "#{to_s} Code Camp v#{version}"
  end
end

"Portland".codeCamp(1.0)

However, adding a codeCamp method to all Srings in the system is kind of strange–to my eye it is a least as strange as redefining Float#to_s–so I went looking for something else…

And then I remembered that I could just use Ruby’s ability to simply implement the Proxy Pattern. The way you do this is to redefine a method called method_missing. (Ruby will call this method any time there is no definition for a method that is called.)

I wanted mine to be a class method (static) and not an instance method, so I went ahead and prepended “self” to the method name. Since Ruby strongly adheres to the Principle of Least Surprise, this worked as expected:

class CodeCamp
  def self.method_missing( name, *args )
    puts "#{name.to_s} Code Camp #{args[0]}"
  end
end

CodeCamp.Portland(1.0)

Now, that is getting good. But it also has some problems. It doesn’t work well with cities like San Fransisco. You could make the city name PascalCase (SanFrancisco)&nbsp_place_holder;or use an underscore (San_Francisco), and then it doesn’t really print right. I decided to use underscores and just replace them with spaces. Simple and effective.

Note: I really wanted to use&nbsp_place_holder;PascalCase (aka WikiWord formatting) to do it, but the regex got annoying and let’s not forget that the underscore is very Ruby-ish, even if us .NET programmers find it annoying.

So I ended up with this, which I think is my final answer:

class CodeCamp
  def self.method_missing( name, *args )
    puts "#{name.to_s.sub("_", " ")} Code Camp #{args[0]}"
  end
end

CodeCamp.Portland(1.0)
CodeCamp.San_Francisco(1.5)
CodeCamp.Boston(2.0)

Five lines of code. Not bad.

(Of course you could wrap it up in a Community module (namespace), but I just didn’t see the point.)

Enjoy!

Update 2005-07-17: Craig Andera correctly pointed out that I said CamelCase when I meant PascalCase.&nbsp_place_holder;Oops. Corrected. (See also WikiPedia - Internal Capitalization).

Geek Notes 2005-07-14

Wow. I guess becoming the dev lead on a project at Microsoft distracted me from the blog a little bit, eh? No Geek Notes posts since May 9th. Oops.

  • String Resource Tool - Scott and I tried to convince them to let us release this last year when we were getting ready to ship EntLib 1.0. If you saw the localizable string resouce stuff in there and wanted to do it yourself, then go get this tool. (Note: If you’re using Whidbey you don’t need it, but if you are on .NET 1.x, go get it.)
  • Photos of the CAB War Room - There is nothing better than having your team all in the same room collaborating. I gladly gave up my office to get this. Music rocking, whiteboards everywhere, people talking and yelling and fighting. It doesn’t get any better than this. (Thanks to Kzu for taking and posting the photos.)
  • MSIZap and MSIInv - I thought I blogged these last year, but I can’t find the post. So I must not have. These are two must have tools for your thumb drive. They let you really see what is installed and clean them up. (Scott should add these to his Ultimate Tools List.)
  • Notepad2 Ruby Highlighting - I’ve been telling people that Ruby was cooler than Python since the big Python rush last year and it looks like people are finally starting to agree. Now if we could only get a CLR implementation al would be right in the world. BTW, I use VIM and have had Ruby highlighting forever.
  • FinePrint - HmmmΓǪ looks good, and when Mr. Hanselman gushes this much, you’ve at least gotta take a look.
  • Visual Studio Guidelines - I saw John Robbins using these in a kick-ass debugging class he led at MS last week. Now he’s blogged it so I don’t have to email him to ask what the reg key was.

My Movie List

I just saw this movie meme on Brad Wilson’s blog.

Here’s the rules: Italicize the ones you’ve seen and Bold the ones you actually liked.

_1. Titanic (1997) - $600,779,824
_2. Star Wars (1977) - $460,935,665
3. E.T. the Extra-Terrestrial (1982) - $434,949,459
**4. Star Wars: Episode I - The Phantom Menace (1999) - $431,065,444
_**5. Spider-Man (2002) - $403,706,375
6. Lord of the Rings: The Return of the King, The (2003) - $377,019,252
**7. Passion of the Christ, The (2004) - $370,025,697
**8. Jurassic Park (1993) - $356,784,000
**
9. Shrek 2 (2004) - $356,211,000
**10. Lord of the Rings: The Two Towers, The (2002) - $340,478,898
11. Finding Nemo (2003) - $339,714,367
12. Forrest Gump (1994) - $329,691,196
**13. Lion King, The (1994) - $328,423,001
**14. Harry Potter and the Sorcerer’s Stone (2001) - $317,557,891
15. Lord of the Rings: The Fellowship of the Ring, The (2001) - $313,837,577
**16. Star Wars: Episode II - Attack of the Clones (2002) - $310,675,583
_17. Star Wars: Episode VI - Return of the Jedi (1983) - $309,125,409
18. Independence Day (1996) - $306,124,059
_19. Pirates of the Caribbean (2003) - $305,411,224
**20. Sixth Sense, The (1999) - $293,501,675
21. Star Wars: Episode V - The Empire Strikes Back (1980) - $290,158,751
**
22. Home Alone (1990) - $285,761,243
23. Matrix Reloaded, The (2003) - $281,492,479
**24. Shrek (2001) - $267,652,016
25. Harry Potter and the Chamber of Secrets (2002) - $261,970,615
**26. How the Grinch Stole Christmas (2000) - $260,031,035
**27. Jaws (1975) - $260,000,000
28. Monsters, Inc. (2001) - $255,870,172
29. Batman (1989) - $251,188,924
30. Men in Black (1997) - $250,147,615
31. Toy Story 2 (1999) - $245,823,397
32. Bruce Almighty (2003) - $242,589,580
33. Raiders of the Lost Ark (1981) - $242,374,454
**
34. Twister (1996) - $241,700,000
**35. My Big Fat Greek Wedding (2002) - $241,437,427
36. Ghost Busters (1984) - $238,600,000
37. Beverly Hills Cop (1984) - $234,760,500
38. Cast Away (2000) - $233,630,478
**
39. Lost World: Jurassic Park, The (1997) - $229,074,524
40. Signs (2002) - $227,965,690
41. Rush Hour 2 (2001) - $226,138,454
_42. Mrs. Doubtfire (1993) - $219,200,000
43. Ghost (1990) - $217,631,306
_44. Aladdin (1992) - $217,350,219
**45. Saving Private Ryan (1998) - $216,119,491
**46. Mission: Impossible II (2000) - $215,397,30
47. X2 (2003) - $214,948,780
_48. Austin Powers in Goldmember (2002) - $213,079,163
_**49. Back to the Future (1985) - $210,609,762
50. Austin Powers: The Spy Who Shagged Me (1999) - $205,399,422
51. Terminator 2: Judgment Day (1991) - $204,843,350
52. Exorcist, The (1973) - $204,565,000
**53. Mummy Returns, The (2001) - $202,007,640
_54. Armageddon (1998) - $201,573,391
_55. Gone with the Wind (1939) - $198,655,278
56. Pearl Harbor (2001) - $198,539,855
**57. Indiana Jones and the Last Crusade (1989) - $197,171,806
58. Toy Story (1995) - $191,800,000
59. Men in Black II (2002) - $190,418,803
60. Gladiator (2000) - $187,670,866
61. Snow White and the Seven Dwarfs (1937) - $184,925,485
**
62. Dances with Wolves (1990) - $184,208,848
63. Batman Forever (1995) - $184,031,112
**64. Fugitive, The (1993) - $183,875,760
65. Ocean’s Eleven (2001) - $183,405,771
**66. What Women Want (2000) - $182,805,123
**67. Perfect Storm, The (2000) - $182,618,434
**68. Liar Liar (1997) - $181,395,380
_69. Grease (1978) - $181,360,000
_70. Jurassic Park III (2001) - $181,166,115
**71. Mission: Impossible (1996) - $180,965,237
**72. Planet of the Apes (2001) - $180,011,740
**73. Indiana Jones and the Temple of Doom (1984) - $179,870,271
**
74. Pretty Woman (1990) - $178,406,268
75. Tootsie (1982) - $177,200,000
76. Top Gun (1986) - $176,781,728
**77. There’s Something About Mary (1998) - $176,483,808
78. Ice Age (2002) - $176,387,405
79. Crocodile Dundee (1986) - $174,635,000
**80. Home Alone 2: Lost in New York (1992) - $173,585,516
81. Elf (2003) - $173,381,405
_82. Air Force One (1997) - $172,888,056
_**83. Rain Man (1988) - $172,825,435
84. Apollo 13 (1995) - $172,071,312
85. Matrix, The (1999) - $171,383,253
**86. Beauty and the Beast (1991) - $171,301,428
87. Tarzan (1999) - $171,085,177
**88. Beautiful Mind, A (2001) - $170,708,996
89. Chicago (2002) - $170,684,505
**
90. Three Men and a Baby (1987) - $167,780,960
91. Meet the Parents (2000) - $166,225,040
**92. Robin Hood: Prince of Thieves (1991) - $165,500,000
**
93. Hannibal (2001) - $165,091,464
**94. Catch Me If You Can (2002) - $164,435,221
95. Big Daddy (1999) - $163,479,795
**
96. Sound of Music, The (1965) - $163,214,286
97. Batman Returns (1992) - $162,831,698
_
98. Bug’s Life, A (1998) - $162,792,677
99. Harry Potter and the Prisoner of Azkaban (2004) - $161,963,000
100. Waterboy, The (1998) - $161,487,252 **

Of course missing from this list is one of the best movies of all time: The Godfather Part I and Part II. And yes, as you can see, I boycotted Star Wars Ep 2 and 3 after seeing Ep 1.

And if you want to see something funny, go see Scott Densmore’s list. Apparently he likes anything.

Quotes From the CAB War Room

While working in the CAB war room (like the Delta Lounge[1] but bigger), there are a number of utterances that I seem to say all the time…

“Use inheritance to be reused, not to reuse.”

This is a bad mis-quoting from C++ Coding Standards: 101 Rules, Guidelines, and Best Practices. In it, Herb Sutter and Andrei Alexandrescu write, “Public inheritance is substitutability. Inherit, not reuse, but to be reused.” It continually amazes me how often developers will derive from a base class to reuse its functionality when they don’t actually mean for the new class to be substitutable for the other.

Additional reading: The Liskov Substitution Principle

“Nothing is better than deleting code and having your tests still pass.”

Assuming you have a nice test harness with good code coverage, nothing makes me happier than deleting code from the production system and leaving the unit tests working. After all, if the test doesn’t need it to pass, you don’t need it to be there.

Or, maybe you’re missing a testΓǪ

&nbsp_place_holder;“That class? I deleted it. There weren’t any tests, so I figured someone just forgot to delete it.”

&nbsp_place_holder;I did this a lot at the beginning of CAB, when I was still trying to “bend the team to my TDD will”. &nbsp_place_holder;In the end it had the desired result, and in fact, may have caused a bit of excess. But better that than no unit tests at all.

[1] Ron Jacobs did a couple of podcasts about The Delta Lounge here and here.

Composite UI Application Block Tech Preview 1 Now Available

If you’ve been wondering why I haven’t been posting as much as I used to, it is because I’ve been leading the development of the newest patterns & practices deliverable, the Composite UI Application Block (aka CAB).

What is the CAB?

The Composite UI Application Block - Community Technical Preview is a source code-based component built on the Microsoft .NET Framework 2.0 Beta 2 that provides proven practices to build complex smart client user interfaces. It is based on proven design patterns in which rich and complex user interface solutions can be built out of simpler user interface parts that can be independently developed, tested, versioned and deployed.

It provides guidance on the architecture of your solution leveraging platform features of the .NET Framework including Windows Forms and ClickOnce.

The application block is designed to separate the different parts of software development, enabling each developer or team to concentrate on their area of expertise. For example, business logic, infrastructure components, or user interface components. The application block provides a framework that shell developers can use to link all of these distinct parts of the application together into a loosely-coupled, yet collaborating set of components to create a fully functioning application.

This is the 1.0 Tech Preview release of CAB, and provides a rich foundation for building smart client and Windows Forms applications in .NET 2.0. We will be continuing to expand the developer experience and the capabilities in the coming months, so please get involved by joining the community site if you haven’t already.

I have had the pleasure of working on this block with an amazing team of people:

This is one of the finest teams of developers, architects, testers, writers, program managers and product managers I’ve ever worked with and I want to thank all of them publicly for doing such fine work.

We are targeting a final release at the same time as the Whidbey launch, but we will also be refreshing the code on our community site. Now that we have made our June 30 tech preview launch, I will be blogging&nbsp_place_holder;a lot more about many of the interesting techniques we are using in CAB. I’m sure the other bloggers on the team (those with links in the list above) will be blogging about it too.

To download the block, please visit http://msdn.microsoft.com/library/en-us/dnpag2/html/cabctp.asp. We just posted that page, so if it isn’t there yet when you try, wait a little while and try again.