Morning Coffee 102

Seems like a slow week.

  • Jules and I went to see the latest Harry Potter movie this past weekend. It’s easily the weakest of the six HP stories so far. The first two stories were about discovering this magical world, the next two about discovering Harry’s past, and the last two about confronting said past. That leaves OotP as the odd-story-out, mostly bridging from the end of the fourth story to the start of the sixth.
  • Speaking of movies, the new movie feature of Mobile Search v2 rocks, though I have two quick suggestions. First, it would be nice to have a time-sorted view of when a given movie is playing. So if it’s playing at 4pm at one theater and 4:30pm at another, you’d see them in a list ordered that way. Second, how about an option to buy tickets directly from the phone?
  • If you’re interested in WPF and 3D, Eric Sink has a series for you.
  • Old news, but Windows Home Server RTMed on Monday. I’m really looking forward to this product.
  • I was looking for some information on how WCF pumps messages in the service host and I found this post from Maheshwar Jayaraman. Between that post and Reflector, I think I’ve got a good handle on how ChannelDispatcher works.
  • Larry O’Brein callsoutthree MS Research Projects. Microsoft Research Accelerator is a high-level data-parallel library that targets GPUs. Graph Layout Execution Engine (aka GLEE) is a library for graph layout and viewing. VirtualEarth MapCruncher converts existing maps (PDF and bitmaps) to work with Virtual Earth.
  • Ted Neward weighs in on the David Chappell’s Korean War REST vs. WS-* analogy. Skim the history lesson, but make sure you read his points about security and reliability interop. WS-* has addressed these areas, so if you need those capabilities, why wouldn’t you use WS-* to get them rather than re-invent the wheel? As for the history lesson, Ted does say he thinks software development is more analogous to making war than building a house. He expands on that idea and recommends Robert Greene’s The 33 Strategies of War. I want to read the book and mull it over a bit, but I certainly see where Ted’s coming from.

Wired for Sound

One of the cool things about my house is that it has built in speakers in four rooms and the back deck. Shortly after we first moved in two years ago, we had a combination house warming and Rileyanne’s christening party. As you might expect, one of the top priorities for said party was music, so I hooked up both my main surround sound receiver plus an old receiver I’ve had forever and we had tunes pumping everywhere except the dining room (which no one was in anyway).

Then, sometime this past winter, I got tired of NOT having surround sound for my HDTV so I redid the sound system. You might be surprised that it took me over a year to get to that, but remember the part about above about “Rileyanne’s christening”? I had other priorities. Anyway, I hooked up the surround sound, including the set of built-in rear speakers in the TV room, and banished the old receiver back to the garage.

Now, it’s summer again. We spend lots of time outside and on the back deck, but now sans tunes. So I’m re-configuring the sound system again, this time so I can get both surround sound and music in the house. Given that it’s a fairly custom speaker setup, I don’t think there’s an affordable off-the-shelf solution that works for this house.

In the long run, I’m thinking of building a custom amplifier that can drive four sets of speakers (one of the sets in the house is the back surround sound speakers, so they’re already taken care of) plus some type of UPnP AV client device. Gainclone chip amplifiers look fairly simple to build – three resistors, two capacitors and the chip itself times eight + a power supply. As for the AV client, I haven’t really investigated yet, but whatever solution I go with has to have high WAF (aka Wife Acceptance Factor).

Of course, building a custom amplifier takes time, so I figured in the short run I’d dust off the old banished receiver and use it to drive two sets of speakers. I also have an old laptop with a bad battery circuit. It can’t roam, but it can sit there by the TV and pull music off my loft computer and play feed it into said old receiver just fine. It’s not a high WAF solution, but it’s something I could put together with parts I had at home + one 1/8″ to RCA cable from Radio Shack. I figured I could get this up and running over the weekend. Almost, but not quite.

I hit one snag with WMP 11 for XP. My office machine and my laptop are both running Vista. All my music is on my office machine, but I use WMP 11′s media sharing capabilities (previously known as Windows Media Connect) to make that media available on my Xbox. I figured I could do the same with the old laptop, using WMP 11 as the AV client. Being an old laptop it can’t run Vista so I installed a fresh copy of XP instead. However, while WMP 11 XP can share media, it can’t consume shared media the way WMP 11 Vista can. Best laid plans and all that.

The workaround is to expose the media via file sharing. Simple enough, except now you have to make sure the security is correctly configured between the two machines. Since it’s a single function device, I hadn’t bothered to set up a password for the default user. Now, in order to access files off the network, I guess I’ll have to.

Once I fix this little file sharing and security problem, I think I’m going to start by looking for a better AV client solution. I know I need a custom amplifier if I want to drive all my speakers, but with my old amp I get music in the kitchen and on the back deck which is where we want it most. On the other hand, the AV Client is the main user experience, so perhaps I should pay it more attention. I’d love to have a solution that is drivable on the TV via the remote while also isn’t built on a seven year old slightly busted laptop.

Any suggestions?

Ovechkin as Superman

Just saw this over on Japers’ Rink and had to share. This video won a three 2007 Golden Matrix award from the Information and Display and Entertainment Association (IDEA): Best Music Video, Best Overall Video Display (hockey) and Best Overall Video Display (overall). More details on Kukla’s Korner. Congrats to the Caps PR team.

Next season is only a little under three months away. Given the moves the Caps have made this off season, next season should be a sight better than last season. Playoffs? Maybe. Contending for playoffs? Probably? Cup Contenders? Check back in a couple more years!

Morning Coffee 101

  • In doing a little LINQ research, I stumbled upon Wes Dyer’s Yet Another Language Geek blog. Fascinating stuff. Subscribed. Be sure to check out his recent posts about Partial Methods, another new C# 3.0 (and VB9) language feature.
  • Werner Vogles has a great post on what a CTO does, including a summary of four different approaches to the job.
  • Somasegar lets us know that even though VS08 doesn’t launch until February of next year, MSFT is “still aiming to release Visual Studio 2008 and .NET FX 3.5 by the end of this year”.
  • There’s a new version of the Windows Live Mobile Search client. The Virtual Earth / Live Search team blog has the details. New features include Movie Showtimes, More Local Data with Reviews and improved Maps and Directions (including GPS integration). Can’t wait to get this installed. (via Dare Obasanjo)
  • XNA Gamefest is coming up next month. It’s sort of like PDC for game developers. It’s where we make our big game dev announcements – last year, we announced XNA GSE there. They recently published their session abstracts, including a whole track on XNA Game Studio Express. As Shawn Hargreaves points out, an “enterprising reader could probably make a good guess” about some of the new stuff getting announced @ Gamefest.

Thoughts on C# Fluent Interfaces

Martin Fowler points to a couple of articles by Anders Norås on building internal / embedded domain specific languages in C#. Anders has built a DSL for creating calendar events and tasks, like you might expect to do in Outlook. Here’s an example:

ToDoComponent planningTask =
   Plan.ToDo("Plan project X").
      StartingNow.
      MustBeCompletedBy("2007.08.17").
      ClassifyAs("Public");
planningTask.Save();

EventComponent planningMeeting =
   Plan.Event("Project planning meeting").
      RelatedTo(planningTask).
      WithPriority(1).
      At("Head office").
      OrganizedBy("jane@megacorp.com", "Jane Doe").
      StartingAt("12:00").Lasting(45).Minutes.
      Attendants(
         "peter@megacorp.com",
         "paul@megacorp.com",
         "mary@contractor.com").AreRequired.
      Attendant("john@megacorp.com").IsOptional.
      Resource("Projector").IsRequired.
      ClassifyAs("Public").
      CategorizeAs("Businees", "Development").
      Recurring.Until(2008).EverySingle.Week.On(Day.Thursday).
      Except.Each.Year.In(Month.July | Month.August);
planningMeeting.SendInvitations();

It may not be as clean as a say a Ruby version might be, but even with all the parens and periods it’s still pretty readable. Fowler calls this a fluent interface, a term I like better than “internal DSL”.

Two things jumped out at me reading Anders’ entry on how he built this fluent interface. First, there’s a lot of code to make this work. Anders didn’t publish the code, but he did admit:

“Believe me, there will be a lot of code when you’re done. I’m almost there with this DSL, and at the time of writing it consists of 58 classes not including the API and tests.”

That’s 58 classes just to implement the fluent interface, not counting the underlying EventComponent API. That’s a lot of non-business logic code to write. How many projects are willing to invest that kind of time and effort to build a fluent interface? (I would guess “not many”)

However, I bet there’s a lot of template-izable code in Anders fluent interface. When he writes about keeping the language consistent by “creating branches within our grammar using different descriptor objects”, I can help but think about parser development with YACC and the like. These tools typically use a DSL like BNF. Maybe we could build a DSL for building fluent interfaces?

Second, Anders makes a very interesting point about the structure of the fluent interface code:

Writing DSLs is a little different from the regular object oriented programming style. You might have noticed that the Plan class has a verb for its name rather than the usual noun. This allows us to have a natural starting point for writing out the “sentence” explaining our intention.

Where have you seen this verb based approach before? Powershell cmdlets.

Windows PowerShell uses a verb-noun pair format for the names of cmdlets and their derived .NET classes. For example, the Get-Command cmdlet provided by Windows PowerShell is used to retrieve all commands registered in the Windows PowerShell shell. The verb part of the name identifies the action that the cmdlet performs. The noun part of the name identifies the entity on which the action is performed.
[Cmdlet Verb Names, MSDN Library]

I’ve written about this aspect of PowerShell before:

In OO, most of the focus is on objects, naturally. However, administrators (i.e. the target audience of PS) tend to be much more task or action focused than object focused. Most OO languages don’t have actions as a first class citizens within the language. C# and Java don’t even allow stand alone functions – they always have to be at least static members of a class.

I’m fairly sure there are many reasons why strongly typed OO languages aren’t popular among administrators. I’m not going to go down the static/dynamic typing rat hole here, but I would guess the object/action language tradeoff is almost as important as the typing tradeoff. What’s nice about PowerShell is that while it has strong object support, it also has strong action support as well. In PS, actions are called Cmdlets. While I’m not a big fan of the name, having first class support for them in PS is one of the things I find most interesting.
[Perusing Powershell Part 1: Get-SQLServer, DevHawk]

While there is no first-class support for verbs or actions in C#, it looks like Anders has essentially rolled his own. For example, his Plan.Event() method returns a new EventDescriptor object. Subsequent calls on this object (RelatedTo, WithPriority, OrganizedBy) change the internal state of this EventDescriptor object. When you reach the end of the chain of calls, EventDescriptor has an implicit EventComponent cast operator that creates a new EventComponent with all the data that’s been collected along the chain by the EventDescriptor.

Again, I can help but think a significant amount of code in this approach can be generalized and the creation automated. Also, I wonder if any of the new C# 3.0 capabilities could be used to improve the implementation. For example, would Extension Methods make it easier to build the fluent interface? Maybe / Maybe not. Regardless, Anders has given me a lot to noodle on.