Passion * Technology * Ruthless Competence

Thursday, March 20, 2008

WebDev.WebServer PowerShell Function

In experimenting with NWSGI yesterday, I found I wanted the ability to launch the development web server that ships with Visual Studio (WebDev.WebServer.exe) from the command line. I hacked up the following PowerShell function and dropped it into my $profile so I can easily launch the web server in any directory any time I need. Thought I'd share:

function webdev($path,$port=8080,$vpath='/')  
{  
    $spath = 'C:\Program Files\Common Files\microsoft shared\DevServer\9.0\WebDev.WebServer.EXE' 

    $rpath = resolve-path $path 
    $params = "/path:`"$rpath`" /port:$port /vpath:$vpath" 

    $ignore = [System.Diagnostics.Process]::Start($spath, $params
    "Started WebDev Server for '$path' directory on port $port" 
}

There's probably an easier way to launch an exe with parameters than Sys.Diags.Process.Start, but it works. Using resolve-path is the key, that lets me pass in a relative path on the command line, but the script converts it to an absolute path in order to pass it to the webdev server. Also, I'm not sure I should have hard coded the path to the exe, but again it works and it's not like it's tough to change.

Enjoy.

Update: Tomas Restrepo pointed out an easier way to start the process:

&'C:\Program Files\Common Files\microsoft shared\DevServer\9.0\WebDev.WebServer.EXE' "/path:$rpath" "/port:$port" "/vpath:$vpath"

I couldn't figure out how to correctly launch the exe when the physical path to serve has a space in it. Thanks Tomas.

Posted By Harry Pierson at 2:39 PM Pacific Standard Time

Tuesday, March 18, 2008

Lunchtime Coffee 158

  • My friend (and hopefully my next representative) Darcy Burner is leading a group of congressional challengers in publishing A Responsible Plan To End The War In Iraq. I haven't read the plan itself in detail, but I sure like what I'm hearing about it.
  • Speaking of politics, Obama's speech today "A More Perfect Union" was fantastic.
  • Bioshock is getting a sequel. 'nuff said.
  • There's a new version of FolderShare out and I've got mixed feelings about it. On the one hand, I've been a regular user of FolderShare for a while so it's nice to see it get a face lift. On the other hand, it's been over two years since Microsoft bought FolderShare and we're only just now getting a new version, which is literally nothing more that a face lift - this version introduces no new functionality at all.
  • I was hoping to geek out vicariously via someone else's hacking around with Singularity. Luckily, Matthew Podwysocki provides just such an opportunity.
  • Looks like "Prism" is the new CAB. Glenn Block has two extensive posts covering a project overview and their first drop. I think it's interesting that the Prism team is focused on building a reference implementation, and letting the framework eventually fall out. Reading thru the description, it sounds awesome. However, based on the massive increase of inbox throughput I'm experiencing since I accepted the new job, I can't imagine I'll have time to play with it. Maybe Matthew will start playing with Prism too! (via Sam Gentile - btw, thanks for the kind words on the new job Sam!)
  • Speaking of Sam, he points to a series by Bob Beauchemin entitled LINQ to SQL and Entity Framework: Panacea or evil incarnate? With a title like that, who can resist reading the whole series? Err, I can because LINQ 2 SQL & EF performance just fell off my radar entirely. However I gotta agree with Sam's point that he "can't think of anyone more qualified than Bob" to tackle these questions.
  • Tomas Restrepo blogs his dev environment PS script as well as a PS fortune script. Personally, I use Chris Tavares' vsvars wrapper for PS, though I'll gladly take an "official" PS based dev environment.
  • I wonder if Ted Neward will get jumped for admiring Mort the way Nick Malik did. Given that Ted called himself Mort while Nick compared Mort to agile developers, I'm guess Ted will have to go back to his Vietnam analogy if he wants to create controversy.
  • Speaking of Ted, I agree with his point that conferences are about people. As a python pre-newbie (I figure I'll reach full newbie status by the time I actually start my new job), I spent most of my PyCon time connecting with people rather than trying to learn technical stuff. Also, I love Ted's WHISCEY acronym.
  • Speaking of PyCon, my soon-to-be new teammate Srivatsn Narayanan blogs his thoughts on PyCon. I'll try and get to my PyCon thoughts soon.
Posted By Harry Pierson at 11:49 AM Pacific Standard Time

Tuesday, February 19, 2008

Morning Coffee 147

  • My son Patrick turns five today. The big treat was his cousin Jack coming up for a visit. Here's a picture of the two of them at Patrick's party on Saturday. My wife has all the details on her blog. Update: My wife just posted a whole slew of Early Patrick Pictures.
  • If my son is five, it means this blog is also five - I started this blog about a month before Patrick was born. I never remember to mark the occasion until Paddy boy's big day comes around.
  • Major props to the House of Representatives for growing a backbone and not caving to President 30% Approval on telecom immunity...yet. Personally, I'd like to see the House bury the measure completely, though I'm not holding my breath. But given that even the right-wing Washington Times reports "Analysts say FISA will suffice", maybe the House Dems will do the right thing.
  • After tearing it up since Thanksgiving, the Caps have gone a little cold. 5-4-1 in their last ten and 2-2-1 in their last five. In the month of February, they're 1-3-1 against SE division opponents. Good news is that they're still even with Carolina (two points behind with two games in hand), half a game up on Atlanta, a game and a half up on Florida and two and a half games up on Tampa Bay.
  • Bill Gates announced a new program called DreamSpark to provide college students access to all of Microsoft's developer and designer tools, including Visual Studio, Expression, SQL Server, Windows Server and XNA Creators Club membership. This looks like an outgrowth of the MSDN Academic Alliance program. I think it's a great idea. Update: Looks like high-school students will be able to access the DreamSpark program too. However, since they're minors, they have to get the software via their teachers. (via LiveSide)
  • The winners of the XNA Silicon Minds contest have been announced. Of the five winners, Specimen looks the coolest to me. I wish I had more time to get into game development. (Via LetsKillDave)
  • Speaking of game development, this week is the Game Development Conference, so be on the lookout for lots of game-related news. Xbox Live VP John Schappert is giving a keynote on "Unleashing the Creative Community". XNA GM Chris Satchell said last year they would "announce full details on, and ... vision for, opening XNA creations to the community" sometime this year. I'm guessing this is said announcement.
  • Speaking of Xbox, there's a rumor that Microsoft and Netflix will announce this week that Netflix is bringing their Watch Instantly service to Xbox 360. If true, sign me up!
  • Grigori Melnik announces the GAX/GAT February 2008 final release. Key feature is VS08 support. Is it just me, or does calling it the "final release" make it sound like they won't be upgrading GAX/GAT further?
  • Speaking of p&p, Grigori also announces the Feb 2008 CTP of Unity, p&p's new IoC container. I've seem lots of folks echoing the announcement, but not much in the way of specifics on Unity itself. For example, Chris Brandsma describes IoC and mentions Unity, but he doesn't cover any Unity specifics. :(
  • MSIT EA Nilesh Bhide has started blogging. His first post is on Customer perception of Service Quality in S+S/SaaS. I've worked closely with Nilesh in the past two years, so I'm excited to see him take to the blogosphere. (via Nick Malik)
  • I don't know how I missed it, but the MSDN Code Gallery launched last month. As Charlie Calvert explained, this is logical successor to GotDotNet's user samples area. Between Code Gallery and CodePlex, GotDotNet has finally been shuttered for good.
  • Telligent, makers of the very popular Community Server, have released Graffiti CMS, which looks like a more flexible content platform than Community Server. (via DNK)
  • In somewhat unexpected news (at least, unexpected by me) Microsoft has released specs for the Office binary file formats. I'm not sure why this is happening now, rather than say when we released the specs for the Open Office XML file formats. (via DNK)
Posted By Harry Pierson at 11:29 AM Pacific Standard Time

Thursday, January 31, 2008

Morning Coffee 141 - Lang.NET '08 Edition

header I was hoping to blog my thoughts on Lang.NET as the event went along. Obviously, that didn't happen, though I was pretty good about dumping links into my del.icio.us feed. The talks were all recorded, and should be up on the website in a week or two. Rather than provide a detailed summary of everything that happened, here are my highlights:

  • The coolest thing about conferences like this is what John Rose called "N3" aka "Nerd-to-Nerd Networking". It was great to meet in person, drink with and geek out with folks who's blogs I read like Tomas Petricek, Wesner Moise and Larry O'Brien. Plus, I got to meet a bunch of other cool folks like Gilad Bracha, Stefan Wenig and Wez Furlong. That's worth the price of admission (which was admittedly nothing) right there.
  • Coolest MSFT talk: Martin Maly "Targeting DLR". I was wholly unaware that the DLR includes an entire compiler back end. Martin summarized the idea of DLR trees on his blog, but the short version is "you parse the language, DLR generates the code". That's pretty cool, and should dramatically lower the bar for language development. Of course, I want to write my parser in F#, so I'm going to port the DLR ToyScript sample to F#.
  • Runner-up, Coolest MSFT talk: Erik Meijer "Democratizing the Cloud with Volta". Erik is a great speaker and he really set the tone of his session with the comment "Division by zero is the goal, not an error". He was referring to an idea from The Change Function that user's measure of success is a function of perceived crisis divided by perceived pain of adoption. Erik wants to drive that adoption pain to zero. It's a laudable goal, but I remain unconvinced on Volta.
  • Coolest Non-MSFT talk: Gilad Bracha "Newspeak". Newspeak is a new language from one of the co-authors of Java. It's heavily smalltalk influenced, and runs on Squeak. He showed developing PEGs in Newspeak, and they were very compact and easy to read, easier even than F#. He calls them Executable grammar, and you can read his research paper or review his slides on the topic. Unfortunately, Newspeak isn't generally available at this time.
  • Runner-up, Coolest Non-MSFT talk: Miguel de Icaza "Moonlight and Mono". The talk was kinda all-over-the-place, but It's great to see how far Mono has come. Second Life just started beta testing a Mono-based script runner for their LSL language (apparently, Mono breaks many LSL scripts because it runs them so fast). He also showed off Unity, a 3D game development tool, also running on Mono.
  • Resolver One is a product that bridges the gap between spreadsheets and applications, entirely written in IronPython (around 30,000 lines of app code and 110,000 lines of test code, all in IPy). Creating a spread-sheet based app development environment is one of those ideas that seems obvious in retrospect, at least to me. If you do any kind of complicated spreadsheet based analysis, you should check out their product.
  • If you're a PowerShell user, you should check out PowerShell+. It's a free console environment designed for PowerShell and a damn sight better than CMD.exe. If you're not a PowerShell user, what the heck is wrong with you?
  • Other projects to take a deeper look at: C# Mixins and Cobra Language.
  • I thought my talk went pretty well. It's was a 15 minute version of my Practical Parsing in F# series. Several folks were surprised I've been coding F# for less than a year.
Posted By Harry Pierson at 10:25 AM Pacific Standard Time

Friday, December 07, 2007

Morning Coffee 128

  • After using Outlook 2007 as my RSS reader for a few months, I've gone back to RSS Bandit. I run two work machines (desktop + laptop) and I finally got tired duplicated blog entries because each copy of Outlook downloads the same post. Also, for some reason Outlook downloads the same Technorati posts over and over again.
  • ADO.NET Entity Framework Beta 3 was released. The latest CTP of the EF Tools is also available. And as per the press release, EF has gained support from "Core Lab, DataDirect Technologies, Firebird Foundation Inc., IBM Corp., MySQL AB, Npgsql , OpenLink Software Inc., Phoenix Software International, Sybase Inc. and VistaDB Software Inc". I'm not sure what that means, exactly, but I guess you'll be able to LINQ to Entities on a wide variety of DB platforms. Interesting Oracle isn't on that list. Not really surprising, but interesting.
  • Here's a new ASP.NET MVC article from Scott Guthrie, this one on views and how you pass data to one from a controller. Using generics to get strongly-typed ViewData is pretty sweet. But where's the MVC CTP that was supposed to be here this week?
  • In news about web app tool previews that did ship this week, Live Labs announces Volta. Haven't installed or played with it yet, but I did read the fundamentals page. It primarily looks like a tool to compile MSIL -> JavaScript, so you can write your code in C# but execute it in the browser. Sam and Jesus are excited, Arnon not so much. Arnon's argument that being able to postponing architectural decisions is to good to be true is fairly compelling, and not just because he quotes me to support his argument. But I'll download it and provide further comment after I experiment with it myself.
  • Simple Sharing Extensions is now FeedSync. Not sure what else is new about it, other than it's been blessed with "1.0" status. The Live FeedSync Dev Center has an introduction, a tutorial and the spec. (via LiveSide)
  • Dare likes tuples. Me too. I also like symbols.
Posted By Harry Pierson at 11:06 AM Pacific Standard Time

Monday, October 08, 2007

Morning Coffee 116

"Looks like I picked the wrong week to stop sniffing glue"
Steve McCroskey, Airplane!

  • So it's been a while since my last post. Just over a month, not including The F5 High, which wasn't "original IP". Frankly, I just stopped reading pretty much cold turkey. I wanted and needed to go heads down on day job stuff for a while. Since I haven't been reading, Morning Coffee is going to be a little cold while I ramp back up.
  • The new NHL season is upon us, and the Caps are looking good so far. Obviously, they have the new uniforms, but they're also out to a 2-0 start for the first time in five years. And in those two games, they've only allowed one goal and are 100% on the PK. It's nice to see them start strong, but obviously there's a long way to go. Here's hoping the can stay strong all season.
  • Speaking of staying strong, the wheels that were rattling last week came off the Trojan bandwagon completely this week. I'm not sure it's as big an upset as Appalachian State beating Michigan but it's close. What happened to the team that scored 5 TD's in a row on Nebraska?
  • Big news last week is that MSFT is going to release the source code to much of the .NET Framework. Scott Guthrie has the details. Frankly, between Rotor & Reflector, it wasn't like you couldn't see the source code anyway, so this seems like a no-brainer. But integrating it directly into the VS Debugging experience, that's frakking brilliant.
  • I haven't had a chance to install the new XML Schema Designer (Aug 07 CTP)  but I was really impressed with this video. The XML Team blog has more details. However, I'm not sure what the ship vehicle is. The CTP install on top of VS08 beta 2, but in the video they keep saying "a future version" of VS, implying that it's not going to be in VS08.
  • Dare is spending some time investigating SSB. I think it's interesting that some of the REST crowd are starting to see the need for durable messaging. Dare argues that the features and usage models are more important than wire protocol. As long as it's standardized, I don't care that much about the protocol. Several of the REST folks mentioned AMQP. While I've got nothing against AMQP technically (frankly, I haven't read the spec), but what does it say about durable messaging vendors (including MSFT) that a financial institution felt the need to drive an interoperable durable messaging specification?
Posted By Harry Pierson at 9:57 AM Pacific Daylight Time

Thursday, August 23, 2007

Morning Coffee 113

  • I'm in Chicago today and tomorrow for a reunion of sorts. In my last job, I managed a group of external architects called the Microsoft Architecture Advisory Board (aka the MAAB). We discontinued the program a while back, but the core of the group found the program valuable enough they have continued to meet anyway. I found the MAAB meetings incredibly valuable and insightful, so I'm really excited to be invited to continue my involvement with the group.
  • I picked up Bioshock Tuesday (Circuit City had it on sale) on my way to my bi-weekly campus excursion. My meetings were over around 2pm so I headed home early, expecting to surprise the kids. But Jules had decided to skip naps and go shopping with them. Her cell phone was dead, so I ended up at home with a couple of hours to myself and a brand new copy of Bioshock. Wow, is that a good game. Certainly deserving of the amazingly good reviews it's garnered.
  • Speaking of reviews, this transparently biased review of Bioshock over at Sony Defense Farce Force is frakking hilarious. Somehow, I doubt their dubious review will stem the tidal wave of Bioshock's well-deserved hype. Can't wait to read their Halo 3 review.
  • Pat Helland writes at length on master-master replication. I reformated it into PDF so I could read it - the large images were messing up the text flow on my system. As usual for Pat, there's gold in that thar post. His thoughts on DAGs of versions and vector clocks as identifiers are very exciting. However, I think he glosses over the importance of declarative merging. I would think programmatic merge would likely be non-deterministic across nodes. If so, wouldn't you end up with two documents with the same vector-clock identifier by different data?
  • Joe McKendrick points to a few people who predict the term "service-oriented" will eventually be subsumed under the general heading of "architecture". Not to brag, but I made that exact same prediction almost three years ago.
  • Erik Johnson thinks that SOA 2.0 centers on transformational patterns. The idea (I think) is that if systems "understand each other more deeply", then we can build a "smarter stack" and design apps via new constructs to promote agility and simplicity. Personally, I'm skeptical that we can define unambiguously system semantics except in the simplest scenarios, but Erik talks about using "graph transformation mathematics" to encode semantics. I don't know anything about graph transformation mathematics, but at least Erik has progressed beyond hand waving to describing the "what". Here's looking forward to the "how".
  • New dad Clemens Vasters somehow finds time to implement an XML-RPC binding for WCF 3.5. I was encouraged that it didn't require any custom attributes or extensions at the programmer level. Of course, XML-RPC fits semantically into WCF's interface based service model, so it shouldn't be a huge surprise that it didn't require any custom extensions. But did it need WCF 3.5? Would this work if recompiled against the 3.0 assemblies?
  • Phil Haack writes a long post on Duck Typing. VB9 originally supported duck typing - the feature was called Dynamic Interfaces - when it was first announced, but it was subsequently cut. I was really looking forward to that feature. Between it and XML Literals, VB9 was really stepping out of C#'s shadow. I guess it still is, even without dynamic interfaces.
  • Since I've been doing some LINQ to XML work lately, I decided to go back and re-write my code in VB9 using XML literals. While XML literals are nice, I don't think they're a must have. First, LINQ to XML has a nice fluent interface, so the literals don't give you that much cleaner code (though you do avoid writing XElement and XAttribute over and over.) Second, I find VB9's template syntax (like ASP <%= expression %>) clunky to work with, especially in nested templates. Finally, I like the namespace support of XNames better. As far as I can tell, VB9 defines namespaces with xmlns attributes just like XML does. So I'm not dying for literal XML support in a future version of C#. How about you?
Posted By Harry Pierson at 7:23 AM Pacific Daylight Time

Friday, August 17, 2007

DataReaders, LINQ to XML and Range Generation

I'm doing a bunch of database / XML stuff @ work, so I decided to use to VS08 beta 2 so I can use LINQ. For reasons I don't want to get into, I needed a way to convert arbitrary database rows, read using a SqlDataReader, into XML. LINQ to SQL was out, since the code has to work against arbitrary tables (i.e. I have no compile time schema knowledge). But XLinq LINQ to XML helped me out a ton. Check out this example:

const string ns = "{http://some.sample.namespace.schema}";

while (dr.Read())
{
    XElement rowXml = new XElement(ns + tableName,
        from i in GetRange(0, dr.FieldCount)
        select
            new XElement(ns + dr.GetName(i), dr.GetValue(i)));
}

That's pretty cool. The only strange thing in there is the GetRange method. I needed an easy way to build a range of integers from zero to the number of fields in the data reader. I wasn't sure of any standard way, so I wrote this little two line function:

IEnumerable<int> GetRange(int min, int max)
{
    for (int i = min; i < max; i++)
        yield return i;
}

It's simple enough, but I found it strange that I couldn't find a standard way to generate a range with a more elegant syntax. Ruby has standard range syntax that looks like (1..10), but I couldn't find the equivalent C#. Did I miss something, or am I really on my own to write a GetRange function?

Update - As expected, I missed something. John Lewicki pointed me to the static Enumerable.Range method that does exactly what I needed.

Posted By Harry Pierson at 4:55 PM Pacific Daylight Time
ADO.NET | Database | Development | LINQ | Ruby | XML

Thursday, August 09, 2007

Fantasy, Free Code and the SharePoint Model

It might sounds like a fantasy, but Nick Malik really wants free code. He started talking about it a few months ago when he was getting raked over the coals by debating Mort with the agile .NET community:

Rather than look at "making code maintainable," what if we look at making code free.  Why do we need to maintain code?  Because code is expensive to write.  Therefore, it is currently cheaper to fix it than rewrite it.  On the other hand, what if code were cheap, or free?  What if it were cheaper to write it than maintain it?  Then we would never maintain it.  We'd write it from scratch every time. 

Then about a week ago, he laid out the reasons why free code would be a good thing. At a high level (Nick's blog has the details), those reasons are:

  1. Lower the cost of IT through reduced skill requirements. 
  2. The speed of development goes up. 
  3. Projects become more agile. 
  4. Solution quality goes up. 

Talking about the benefits of free code is sorta like talking about talking about the benefits of dating a movie star. The benefits are actually pretty obvious, but talking about them doesn't really help you get there from here.

Actually, Nick isn't suggesting that all code can be free. He's focused on separating out business process modeling/development from the rest of software development. In essence, he's describing a new class of developer (should we call the persona Nick as an homage?) who needs their own class of tools and for the IT department to "formally" allow them to "easily develop, test, and deploy [aka host] their processes." For the most part, these BP developers wouldn't be traditional developers. They'd be more like software analysts who do the work directly instead of writing specs for developers.

I call this separation of business and IT concerns the SharePoint Model. SharePoint, IMO, does an amazing job of separating the concerns and needs of business and IT users when it comes to running intranet web sites. Only the truly geeky stuff that requires specialized access, knowledge or equipment - installing the SharePoint farm in the first place, keeping it backed up, installing service packs, etc. - is done by IT. Everything else is done by the business folks. Need a new site? Provision it yourself. Need to give your v-team members access to it? Do it yourself. I see similarities in the free BP code approach Nick's suggesting. I'd even argue that SharePoint is the natural "host" for such business processes. It already supports WF and can provide access to back-end enterprise data via the Business Data Catalog.

On the other hand, some of what Nick suggests seems fairly impractical. For example, he thinks IT should "formally and officially take control of managing the common enterprise information model and the business event ontology." First off, who officially manages this today? Does such an official information model or event ontology even exist? I'm guessing not. That means you've got to start by getting the business people to agree on one. That's usually a sucker's bet. Nick also suggests we "reduce the leaky abstractions" in our services. To suggest this is even possible seems incredibly naive.

The good news is the things that will work (evolving BP into its own development discipline, building custom tools for BP development, getting IT into the BP hosting business) don't depend in any way on the things that wont work (getting lots of folks to agree on anything, breaking the laws of physics, overcoming the law of leaky abstractions). I'm not sure it will result it truly free code, but it sure would bring the costs down dramatically. Thus, I think most of Nick's free code vision is quite practical and not a fantasy at all.

As for dating a movie star, you're on your own.

Posted By Harry Pierson at 4:53 PM Pacific Daylight Time

Wednesday, August 08, 2007

Morning Coffee 109

  • I forgot to add a number to my last morning coffee post. However, after extensive research, I have determined that it was #108. So thing are continuing as usual today with #109. On the other hand, do you really want development and architecture opinions from a guy who can barely count? :)
  • The finalists in the Dream-Build-Play contest have been announced. I haven't played any of them yet (some are available for download) but they several of them sure look good.
  • And speaking of gaming, MS announced an Xbox 360 price drop yesterday. So if you want to get in on some of the XNA action, here's your chance (or you could just build for your PC - take your pick).
  • Finally on the gaming front, if you're not busy Monday you can watch the first day of Gamefest 2007 online. Get the scoop on XNA 2.0 as well as the new XNA networking support. I, alas, am busy Monday so I'll have to catch it on demand.
  • On to, you know, actual geek stuff things. Scott Guthrie seems to have retired his LINQ to SQL series and moved on to LINQ to XML. He shows how to build an RSS reader application with LINQ to XML. An oldie demo, but a goodie.
  • Wanna learn F#, there's a whole site of samples up on CodePlex. (via Don Syme)
  • Jeff Atwood is annoyed at how many different products you have to install to get a current & complete setup of VS 2005. Of course, MS shipped two parts of that stack since VS05 shipped (TFS & DBPro), three service packs (VS05 SP1, SQL 05 SP2 and DBPro SR1) and a major OS upgrade (VS Vista update). Doesn't the same thing happen with any shipping product after a few years? BTW, if this is such a huge hassle, I wonder why Jeff doesn't create a slipstreamed VS installer?
  • Udi Dahan has a great post on estimation where he claims "Developers don’t know how to estimate." No argument, but the way he phrases it sounds like it's the developer's fault they suck at estimation. It's not. Developing - by definition - is building something you've never built before. Is it any surprise we suck at estimating how long it will take us to do something we've never done before?
Posted By Harry Pierson at 10:15 AM Pacific Daylight Time

Wednesday, July 25, 2007

*Now* How Much Would You Pay For This Code?

Via Larkware and InfoQ, I discovered a great post on code reuse by Dennis Forbes: Internal Code Reuse Considered Dangerous. I've written about reuse before, albeit in the context of services. But where I wrote about the impact of context on reuse (high context == low or no reuse), Dennis focused on the idea of accidental reuse. Here's the money quote from Dennis:

Code reuse doesn't happen by accident, or as an incidental - reusable code is designed and developed to be generalized reusable code. Code reuse as a by-product of project development, usually the way organizations attempt to pursue it, is almost always detrimental to both the project and anyone tasked with reusing the code in the future. [Emphasis in original]

I've seen many initiatives of varying "officialness" to identify and produce reusable code assets over the years, both inside and outside Microsoft. Dennis' point that code has to be specifically designed to be reusable is right on the money. Accidental code (or service) reuse just doesn't happen. Dennis goes so far as to describe such efforts as "almost always detrimental to both the project and anyone tasked with reusing the code in the future".

One of the more recent code reuse efforts I've seen went so far as to identify a reusable asset lifecycle model. While it was fairly detailed at the lifecycle steps that came after said asset came into existence, it was maddeningly vague as to how these reusable assets got built in the first place. The lifecycle said that a reusable asset "comes into existence during the planning phases". That's EA-speak for "and then a miracle happens".

Obviously, the hard part about reusable assets is designing and building them in the first place. So the fact that they skimped on this part of the lifecycle made it very clear they had no chance of success with the project. I shot back the following questions, but never got a response. If you are attempting such a reuse effort, I'd strongly advise answering these questions first:

  • How does a project know a given asset is reusable?
  • How does a project design a given asset to be reusable?
  • How do you incent (incentivize?) a project to invest the extra resources (time, people, money) in takes to generalize an asset to be reusable?

And to steal one from Dennis:

  • What, realistically, would competitors and new entrants in the field offer for a given reusable asset?

Carl Lewis wonders Is your code worthless? As a reusable asset, probably yes.

Posted By Harry Pierson at 2:47 PM Pacific Daylight Time

Monday, July 23, 2007

Morning Coffee 104

  • I'm presenting at a an internal training conference today and tomorrow, so my Morning Coffee roundup posts will be lighter than usual. On the other hand, I'm taking a bus downtown to the convention center, so I might write something more substantial on the way there and back. Or maybe I'll just read.
  • My wife's blogging will also be light, because she's got her nose buried in a book. If I do read something to or from the conference, it's not that book because she won't let me near it until she's done! :)
  • Speaking of "that book", Werner Vogel drops a few details about how well Amazon handled 1.3 million pre-orders that were delivered on Saturday (including our copy).
  • First drop of IronRuby is available. For now, you can get it from John Lam's blog. Unlike IronPython, IronRuby will be hosted at RubyForge, not CodePlex, but the site isn't set up yet. Other big news is that the IronRuby team will be accepting external contributions. Are these encouraging signs to the Ruby community?
  • More MS Research goodness: a new drop of Spec# is available. I've written about Spec# before, but haven't had the time to dig into it. (via Larkware)
  • Scott Hanselman takes the red pill. Congrats!
  • Speaking of Scott, he forwards on advice to remove a programmatic crutch. Good advice. Not to go all Petzold on Visual Studio, but I would guess the IDE is the biggest crutch out there. As for giving up compulsively checking email, if that's a goal Scott, I think you might have joined the wrong company...
Posted By Harry Pierson at 8:15 AM Pacific Daylight Time

Thursday, July 12, 2007

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.

Posted By Harry Pierson at 2:38 PM Pacific Daylight Time

Friday, June 22, 2007

Morning Coffee 93

  • newcapsjersey The Washington Capitals unveil their new jersey tonight, though they have a picture on their web site. I've got mixed feelings, though I'm trying to reserve judgement until I see it "in action". I like that they're back to the traditional Caps colors. But the Caps have jersey change fatigue. They only had the screaming eagle jersey for twelve years, and they swapped out the blue jersey for the black one (that started life as a third jersey) somewhere along the line.
  • Lawrence Lessig hangs up his IP spurs to go after the deep corruption of the political process. He points out that after a decade focusing on IP, he's learned all he is going to about these issues so he decided (among other reasons) that it was time to start fresh learning about something new. I keep telling my kids that "always keep learning" is one of the secrets to life. This move by Lessig is the embodiment of that principle. Good for him. (via John Lam)
  • My old team keep chugging along. They've recently added "special coverage" sections on Agile Development and Enterprise Architecture.
  • Miguel de Icaza details the three week "hackathon" (his words, not mine) they went thru to get a working version of Silverlight on Mono - aka Moonlight - in time for ReMix 07 in Paris. It's an impressive engineering achievement, to say the least. Also, it's nice to see the folks from Microsoft France invite Miguel to come be a part of their keynote. (via Larry O'Brien)
  • Rob Bazinet points out VisualSVN in response to my question about SVN clients other than Tortoise. Like AnkhSVN, VisualSVN snaps into Visual Studio. However, where AnkhSVN is a native SVN implementation, VisualSVN depends on Tortoise. Scott Bellware wrote "VisualSVN takes a novel approach to bringing SVN into the Visual Studio IDE... it brings Tortoise into the IDE!". So it still sounds like Tortoise is the SVN client everyone cares about.
  • Scott Berkun details a variety of immature development and management methodologies, including Development By Denial (DBD), Cover Your Ass Engineering (CYAE) and my personal favorite Asshole Driven development (ADD). Scott Hanselman suggests looking around and making sure you're not said asshole. I tend to be somewhat...how should I say it?...strong willed about the direction projects I work on should take. My current project is about driving a paradigm shift to service orientation, and I don't think you can't drive that kind of change without being somewhat strong willed. It's a thin line between strong willed and asshole and hopefully I come down on the right side of that line more often than not.
Posted By Harry Pierson at 9:50 AM Pacific Daylight Time

Wednesday, May 16, 2007

Morning Coffee 78

  • Ian Griffiths posts a much longer version of "Even though the runtime supports multiple languages, most programmers are only fluent in one." (via Larkware)
  • I wrote yesterday that Pat Helland's first post back was light on the tech talk. Luckily (for us) he takes the bus to work so he has plenty of time to write blog entries. Today's post is his "personal opinion about how computers suck". Money Quote: "We try too hard as an industry.  Frequently, we build big and expensive datacenters and deploy big and expensive computers. In many cases, comparable behavior can be achieved with a lot of crappy machines which cost less than the big expensive one."
  • Steve Jones wrote that CRUD is CRAP. I agree 100%, but for additional reasons. Not only is it boooooring to write, it also delegates control outside of the service which I think is a mistake. Check out this post from Maarten Mullender who advised to do CRUD only when you can afford it.
  • MIT Media Lab has created Scratch "a new programming language that makes it easy to create your own interactive stories, animations, games, music, and art -- and share your creations on the web" targeted at kids 8 and up. It's a dynamic visual programming language that looks like Lego. Between Scratch, Boku and Phrogram I think my kids will have lots of fun learning to program like daddy does. (via GeekDad)
  • Halo 3 is coming September 25th! I foresee lots of people calling in sick that day. And the next. And the rest of the week, etc. etc. etc.
Posted By Harry Pierson at 12:01 PM Pacific Daylight Time

Wednesday, May 02, 2007

Hawkeye on Silverlight

While I was crusing the zoo with the family on Monday, everyone else was focused on the big announcement coming out of MIX. Short version of the press release: the next version of Silverlight contains a small, cross platform CLR. As you might imagine, this is somewhat significant. Check out reaction from TechCrunch, Sam Gentile and Scott Hanselman.

A year ago, I wrote "Where else should the CLR live?" At the time, I was talking about XNA (which had just been announced) though I was aware of the plans around what I think is now officially called CoreCLR (got the name from Scott's post). The first time I heard about this, it literally floored me. Part of me is surprised that in the year since then the news didn't leak and no one figured it out. I mean, doesn't it seem sorta obvious, in retrospect, that a Silverlight should run on CLR? I mean, if we can shrink the CLR down to fit on a watch, getting it into the browser seems like a no-brainer. On the other hand, it's such a huge departure from "Windows, Windows, Windows" that I wonder if most people had (have?) a hard time wrapping their mind around it.

(Actually, in searching for CoreCLR, I discovered this post from last summer basically confirming "the CoreCLR team working on the Macintosh version of the MiniCLR that's going into WPF/E". So it did leak, but it seems to have been met with significant skepticism and didn't make much news. )

Now that you know all about Silverlight and CoreCLR, go back and re-read my Virtuous Cycle of Virtual Platforms post. Especially the last paragraph (complete with the bad grammar):

If the end user isn’t committed to a virtual platform like Flash, then who is? The developers who build software for that virtual platform. This is Virtuous Cycle of Virtual Platforms between the platform and developers instead of the platform and users. In the old model, developers go where the users are. In the new model, users go to where developers are. And developers go where they can be most effective.

Silverlight vs Flash looks to me like the next big platform war competition. It's just getting started, so you can't say with any certainty which platform will be "most effective". But early Silverlight reviews are pretty impressive. TechCrunch's Michael Arrington wrote that Silverlight "makes Flash/Flex look like an absolute toy". That doesn't erase Flash Player's head start in the RIA space, but it certainly makes catching and surpassing Flash sound feasible. I suspect most people didn't think that sounded at all feasible last week.

Of course, while catching Flash may sound feasible, Microsoft is a long way from achieving that goal. While the point of my earlier post is that that market penetration doesn't provide much advantage in the virtual platform market, Adobe does derive significant advantage from shipping nine versions of Flash while we haven't quite shipped the first version of Silverlight yet. Also, while I'm fairly sure the number of .NET developers far exceeds the number of Flash developers (anyone have hard numbers?), I would also expect that the number designers using Flash far exceeds the number of designers using Expression (given that MSFT only just shipped Expression on this week). I believe an important facet to the Silverlight / Flash platform competition will be a race to woo the competitor's core constituency. Can Microsoft woo more designers with Expression than Adobe can woo developers with Flex? We'll see.

I'm also curious to see how people's perspective of Adobe's Apollo project changes in the wake of the Silverlight/CoreCLR announcement. From my perspective, both Microsoft and Adobe are trying to unify web and desktop development. Not surprisingly, each is trying to unify around the model where they're stronger: Apollo takes the web development paradigm (Flash, HTML, AJAX and JavaScript) to the desktop while Silverlight takes desktop development paradigm (WPF, CLR) to the web. I'm sure you can guess which paradigm I think will be more successful, but how will the market react? Again, we'll see.

Posted By Harry Pierson at 10:54 AM Pacific Daylight Time

Monday, March 19, 2007

VSTDB, Where Have You Been All My Life?

Honestly, this post started off as a rant entitled "Is it Me, or is DB Development a Pain in the Ass?" about the sorry state of database development tools in Visual Studio. But in searching around on MSDN for information about the built-in "Database Project" type (which could more accurately be called "just a bunch of SQL scripts"), I stumbled across information about the Database Professionals edition of Visual Studio Team System. That's right, I had forgotten that we shipped this late last year.

I short, VSTDB (or whatever the "official" acronym is) is 90% of what I was looking for in a DB dev tool. Sure, it's not perfect, but it's a massive improvement over the previous state of the art.

The primary feature of VSTDB is the ability to "build" your database the same way you build your code. You use lots of small scripts that get compiled together into a model (for lack of a better term) of the database as you've defined it. That model can be deployed to a new database instance or used to update an existing instance. You can also compare that model against an existing database in order to determine what's changed and automatically build update SQL scripts for the DBA's to run in the production environment (since you don't want your developers doing that).

It takes a little getting used to, but the "lots of small scripts" approach has a lot of upside. If you have a table with a primary key, you're supposed to define the primary key, indexes, constraints, triggers, etc. in separate scripts from table creation script. This makes things much easier when you're trying to figure out what's changed in your source control system.

VSTDB has a variety of other cool looking features like data generation and unit testing, but I haven't really dug into them much yet. One thing that VSTDB supports that I wasn't expecting was Service Broker! SQL Management Studio has limited SSB support - if you want to create new SSB objects you have to write the DDL directly. VSTDB requires you to write the SSB DDL also (it makes you write DDL for everything, see below) but it at least has templates for all the SSB object types. Very Cool!

Of course, there are always things that could be improved. The T-SQL editor does syntax highlighting but not IntelliSense. It doesn't support the existing visual database tools like the Table Designer. And while you can build T-SQL stored procs, functions, types, etc, VSTDB doesn't support the development of managed SQLCLR stored procs, et.al. Things to work on for v2, I suppose. 

If you're using VS Team Suite, you can download an add-on that adds VSTDB functionality to your existing VSTS installation. It's only 8MB, so it's definitely the way to go for Team Suite users.

Posted By Harry Pierson at 4:15 PM Pacific Standard Time

Thursday, February 15, 2007

Morning Coffee 32

  • As 24 sputters,