Morning Coffee 112

  • The Lee Holmes over at the Powershell Team Blog writes about alternatives to the “decades-old” Windows console host. Powershell Plus looks awesome. PoshConsole also looks pretty cool (though far from finished yet) and is free.
  • WL IDWeb Authentication SDK has been released. Details on the WL ID team blog. It looks like what Passport SDK provided for quite some time, but now it’s free. There’s also a client auth SDK in development. (via Dare Obasanjo)
  • Libor Soucek leaps to the wrong conclusion about not differentiating enterprise & support systems. Of course, different systems will have different availability requirements. But what happens when we connect them together? We can’t let the support system effect the availability of the enterprise system, right? To me, that implies either a) the support system now needs to conform to enterprise system availability requirements or b) we need some other mechanism (like async durable messaging) to act as a buffer between them. Personally, I like “b”.
  • Nick Carr points to an article The Trouble with Enterprise Software by Cynthia Rettig. Cynthia writes that while the massive complexity of enterprise software, especially large-scale ERP systems like SAP, significantly hinder it’s value. It’s a must read. Choice quotes:
    • “It is estimated that for every 25% increase in complexity in the tasks to be automated, the complexity of the software solution itself rises by 100%.”
    • “The notion of reusable software works on a small scale. Programmers have successfully built and reused subroutines of standard functions. But as software grows more complex, reusability becomes a difficult or impossible task.”
    • “Hope, unfortunately, has never been a very effective strategy.”
    • “Is enterprise software just too complex to deliver on its promises? After all, enterprise systems were supposed to streamline and simplify business processes. Instead, they have brought high risks, uncertainty and a deeply worrying level of complexity. Rather than agility they have produced rigidity and unexpected barriers to change, a veritable glut of information containing myriad hidden errors, and a cloud of questions regarding their overall benefits.”

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.

Morning Coffee 94

  • By most accounts, the Capitals had a good draft this weekend. They started the day with ten picks across the seven rounds. The ended the day with ten prospects as well as three extra picks next year, including two second rounders. According to the GM George McPhee (aka GMGM), next year’s is “supposed to be a terrific draft” which is probably true but what you always say when you trade down for future picks. On the other hand, if the guys you want are available further down, why not stock up on the future picks?
  • John Lam reports on Steve Yegge’s Rails port to JavaScript that he saw at Foo Camp. Google (aka Steve’s employer) wasn’t interested in adopting Ruby or Rails since they already use C++, Java, JavaScript and Python. So Steve ported Rails to JavaScript. Wow. However, it does beg the question which is more valuable, Ruby or Rails? If you could have just one or the other, which would you choose?
  • Speaking of dynamic languages, Powershell Community Extensions v1.1 is out. I want to check out the new Elevate function. Currently, I’m using the Script Elevation PowerToys, but I would rather have a pure PS solution. (via Powershell Team Blog)
  • I always know it’s a slow day when I decide to check TechMeme while writing my Morning Coffee post. Usually, I get plenty to write about from just my news reading. However, right now, even TechMeme seems mostly uninteresting. Only thing remotely interesting to me is Samsung’s new 64GB solid state drive.

Morning Coffee 92

  • Brad Wilson blogs about SvnBridge, a tool that lets you use Subversion clients like TortoiseSVN to talk to Team Foundation Server. While I think that’s cool, I wonder is anyone interested in subversion clients other than TortoiseSVN? For example, will people choose AnkhSVN instead of the Team Explorer Client?
  • Speaking of TortoiseSVN, I wonder if those guys are interested in building a TortoiseTFS project? I did find two other TFS shell extensions projects: Dubbelbock TFS and Turtle, though neither appears as full featured as Tortoise.
  • Scott Guthrie details VS08′s multi-targeting support. Of course, the three versions of the .NET Framework VS08 can target all use the same underlying runtime, which probably made it easier to build.
  • Michael Platt refactors Don Box’s original tenets of service orientation so he can include some information about how these services get built.
  • Scott Hanselman tackles the tricky question of assembly granularity.
  • PowerShell Analyzer is now available for purchase. Among other things your $59 gets you, besides a 50% savings, is “Feature request priority“. That’s pretty cool. I wonder how many other micro-ISV’s take the approach of “pay me now and you get to help me pick some of the new features.”
  • Brandon LeBlanc
    My Monitor Setup
    writes about dual monitor support in Vista. I’m loving the dual monitor support, though I have a somewhat strange setup. I keep my primary monitor rotated in portrait mode, which is great for reading and writing. I typically use my second monitor for blogs and mail. I even wrote a custom multi-mon wallpaper utility so I could easily generate new wallpapers for my non-standard monitor layout, including bitmap rotate support. If there’s interest, I can post it. (via Sam Gentile)
  • Nick Malik continues to write about Mort, with the usual response from the usual folks. I liked his point that “You cannot fight economics with education”, but otherwise I’m staying out of this discussion.
  • In the same vein, Martin Fowler writes about Technical Debt. I completely agree with his hypothesis that short changing design may save time in the short term but will cost much more in the long term. However, the problem is that the people who are making the tradeoff – i.e. the people paying for the project NOT the people building the project – either don’t understand the tradeoff or are more than happy to sacrifice the long term cost for the short term gain. How are most projects measured? Being on time and on budget with the planned set of features. Very few projects – and none that I’ve ever seen – are goaled on long term maintainability. Until you can change that, this issue will continue to linger.

Morning Coffee 91

  • My wife loves me. I’m a very lucky man.
  • I’m starting to really dig Safari Books Online. Having a tablet really helps here, I can sit in bed and read and it’s ALMOST like reading a real book. Is there an offline experience? Something like the NYTimes WPF Reader app would be killer.
  • I’m not a Twitter guy, but I like the idea of using it to publish CI results. Not quite as cool as using the Ambient Orb, but close. (via DotNetKicks)
  • Soma details the dogfood usage of TFS in Developer Division. Sorta interesting if you’re into knowing that stuff. Brian Harry apparently has much more.
  • I realize that linking to Pat Helland every time he writes something is fairly redundant. If you want his feed, you know where to find it. But he writes great stuff! The latest is Accountants Don’t Use Erasers, which talks about append-only computing. His point that the database is a cache of the transaction log is mind blowing, yet makes total sense.
  • Bruce Payette blogs a PS DSL for creating XML documents.
  • Jesus Rodriguez details WCF’s new Durable Service support in .NET 3.5. I get the need for the [DurableServiceBehavior] attribute, but do I really have to adorn each of the service methods with [DurableOperationBehavior] too? That seems redundant. Also, I wonder how this looks at the channel layer?
  • Speaking of WCF’s channel layer, I recently picked up a copy of Inside Windows Communication Foundation by Justin Smith. This is the first book I’ve found that has more coverage of the channel layer than the service layer, so I like it.
  • Dare writes about Web3S, Windows Live’s general purpose REST protocol. Apparently, WL started with Atom Publishing Protocol, but found that it didn’t meet their needs around hierarchy and granular updates. David Ing says it’s “not that similar” to my concept of REST, but I going to read the spec before I comment.
  • Scott Hanselman writes about how he learned to program and some thoughts about teaching his son. Patrick has recently started expressing interest in programming (he want’s to do what Daddy does). At four, I’m thinking I’ll start him on Scratch (though ToonTalk looks interesting). As he gets older, I was thinking about Squeak, though I’m a smalltalk noob. I really like Scott’s idea of creating a connection to the physical world via something like Mindstorms. Patrick loves Lego almost as much as his dad, so that would be cool.