Day 3 - The Premature Conclusion Edition

Technical content of this issue - 4 out of 5

Yesterday's Trivia

Free shout out to Kevin Mineweaser and Andrew Strauch who correctly identified the lyrics to Jimmy Buffett's "Fool Button," although both admit to using search engines (excuse me, Kevin used a "decision engine").

I'm excited to announce that we now have a theme song for the newsletter. Click here and click the "Play direct from..." link on the page that comes up - make sure you listen for at least a minute when the lyrics start. Go ahead, don't read any further until you do it.

You didn't do it, did you? Listen now - click here. It's a slow day, this may be the only laugh in the issue.

Your Next Opportunity for Fame

The significant webcast is definitely having an effect on the conference - timing is very strict. There's even a "director" standing off to the side shouting "1 minute", "30 seconds" and "In 5...4...3...2...1"). I keep waiting for him to say, "Your all a big part of the show. See that sign up there? It says Applesauce." Free BPN shoutout to whoever can name the source of that quote.

Open in the Cloud

Windows Azure and Java

FINRA, the company that pays the bill for my PDC attendance, has a large Java footprint and dedicated Java congregation, so this seemed like a good session for me to attend. Although I've dabbled, I'm largely ignorant in all things Java, so if I misunderstand an issue please don't flame the heretic.

The talk really had two major areas, how Azure can run Java applications and the Eclipse plug-in for Java in Azure.

There are a couple ways you can run Java under Azure. First is to customize a standard Azure worker role. The steps involved in this are-

  • Include the JRE and Java App Server of your choice in the worker role
  • Provide your own App code
  • Launch the app server during the role startup

This appears to be just like you would do it if you were configuring a Windows server. The alternative is to take advantage of Tomcat Solutions Accelerator that provide preconfigured Tomcat solutions.

Once you've got the Java running in Azure you can use any Java libraries you use now, Spring, Struts, etc. Microsoft has also announced this week the release of the Windows Azure SDK, giving Java developers a Java class interface for manipulating Windows Azure Storage & Service Management (Blobs, Tables, Queues, etc.)

Windows Azure Tools for Eclipse

Another new tool announced today was the Windows Azure Tools for Eclipse package. This Eclipse Add-in provides a huge number of features for creating, writing and deploying Java applications for Azure. From an Admin UI that sets up the worker thread with Java app servers to one click deployment, it makes the admin life of a Java dev in Azure much easier. The plug-in will go to CTP release in 2H10 and RTM 1H11.

There's a good demo of the Eclipse plug-in and setting up a Java app on under Azure around the 44 minute mark on the presentation video. It must be good, I see lots of Java-istic words like EAR and JAR and App Server.

Unlocking the JavaScript Opportunity with Internet Explorer 9

This talk centered on all the improvements made in IE9's JavaScript engine, code-named "Chakra." Analysis of the IE8 JavaScript engine revealed the following drawbacks-

  • The script engine was designed for multiple hosts, not just IE, which forced compromises in its design - it was optimized for fast startup and execution and efficient memory utilization
  • The engine lives outside IE, and all interaction is marshalled through the IActive COM interface. This was great for multiple hosts, but imposes a significant performance penalty. Analysis shows that almost half the time bringing up various News sites was spent in JavaScript and marshalling
  • The engine runs in the UI thread

Microsoft addressed all these issues and more with the IE9 JavaScript engine.

First, they added a JavaScript compiler to speed execution of JavaScript. This makes the execution faster, but imposes a startup penalty while the code is compiling. Microsoft solved this by including a (faster) interpreter to handle JavaScript immediately upon startup while a background thread compiles targeted code based on heuristics (it turns out most pages use a very small portion of the JavaScript they download).

Second, they moved the engine inside the browser and gave it direct access to the DOM model - no marshalling.

After analyzing many sites, they found that the most used JavaScript command is not GetElementByID, but StringIndexOf (who knew?). They showed a demo of a script that hammered this command in IE8 and IE9. IE8 hovered around 250ms to complete the test. IE9 ran the test in around 100ms the first time, then the time ramped downward as compilation kicked in, leveling off around 50ms - five times faster than the old engine.

The interpreter was improved by adding a new type system. JavaScript is constantly adding and changing types, so there was great room for improvement in this area. One example is that when a new attribute is added to an object the existing type is extended rather than being deleted and recreated as a new type.

There's a great site on measuring JavaScript performance on different sites on the Microsoft Research site here.

More improvements they touched upon include-

  • They do a first run syntax check
  • The handle the UTF-8 charset directly instead of converting it to UTF-16
  • The bytecode generator is now register based rather than stack based. This enables instruction optimization when compiling and eases mapping to machine hardware.
  • They implemented the Web IDL Spec - DOM objects are now native ECMAScript 5 objects, opening them up for reflection.

Better Code Through Smart Assertions and Unit Tests

This was a very interesting interesting session that wasn't what I expected coming in. It was let by two guys from Microsoft Research and focused on new technologies, Pex and Moles, that are available now.

The first thing they demonstrated was a technology called Contracts that is currently shipping as part of .NET 4.0 in the System.Diagnostics.Contracts namespace. Contracts are essentially like asserts used to check input and exit conditions of a function. Here's an example-

public float AddToCart(Order order)
   // Validates the inputs and throws an exception if they are violated
   Contract.Requires<NullReferenceException>>(order != null);
   Contract.Requires(order.Quantity > 0);
   // Validates the return value
    Contract.Ensures(0 < Contract.Result<float>());

There's alot more to these, there's a more in depth introduction here. The point of these is not to check business logic, but look for structural defects in what's going on in your program.

The next topic was a tool called Pex. Pex analyzes code and determines what inputs are required to get total code coverage. They first demo'ed Pex as part of a coding challenge on In this challenge you are presented with a method signature and are supposed to guess the implementation. Click the Ask Pex button and it will attempt various input values based on its analysis of the solution code and show you the difference between your results and the solution code results. You solve the puzzle when your code returns the same values as the solution code for all values Pex determines are needed for full coverage. Try a few of the randomly selected puzzles that come up on the site, then try the one I wrote for the Newsletter here.

OK, now we have Code Contracts that enforce structural rules on code execution and Pex, a technology that finds edge cases and ensures coverage by analyzing code - c'mon, try to keep up. Pex is also available as a tool that can be downloaded from MSDN and run in Visual Studio. The final piece of the puzzle is Moles, which allows you to replace any .NET method with a delegate. Huh? What the heck does that mean? Let's say you've got a method that you want to test that opens a file, reads the contents and looks for a name/value pair where the name is "foo." Since this has a dependency on an external file, you may or may not be able to test it in your build environment. You'd like to test it without worrying about the dependency on the external file. What if prior to calling the method you could pre-ordain what the ReadAllLines call inside the method would return? Whoa, run that by me again? With a Mole, you can essentially reach inside the tested routine and change the behavior of an internal method call! Then you can set whatever you like as the file contents, you can call the method multiple times with multiple contents. Here's what it looks like-

// When I do this, ReadAllLines inside RoutineToTest will return "Foo=bar" - it's magic!
   MFile.ReadAllLinesString = delegate
      return new string[] { "Foo=bar" };
   retval = RoutineToTest();

Now all the pieces are here, let's put them all together in the VS Test Framework. Once you create one unit test (setup, execute, check result), you can refactor it to pull out the execute part. Then, with Pex installed as an add-in for Visual Studio, you can use it to create more tests with different inputs until you have all the code covered. If you have added strong pre and post condition contracts you will then have at least structurally tested every line of code. You will probably want to add asserts to the generated tests to ensure that the business logic is correct as well. This seems to give you an aid in the grunt work, but asserts driven by business requirements still require thought and effort.

There's lots of tutorials and instruction at Pex4Fun and on Microsoft's sites, if your interest is piqued you should watch the video at the PDC site. I almost forgot, also has implementations of coding duel for Visual Basic and F#.

ASP.NET + Packaging + Open Source = Crazy Delicious

No way I can do justice to this presentation - Scott Hanselman is like Microsoft's version of Robin Williams. If you only watch one session from this PDC on the web, consider this one (FT01) - it's definitely better than a one hour rerun on television.

During the talk, he wrote an MVC.NET Blog app from scratch. I'll just focus on a couple features and technologies that flew by during the extravaganza

NuGet Package Manager

This is a Visual Studio add-in that allows developers to add packages to their Visual Studio project without having to search on the web, download, unzip, etc. Packages available include .NET and Microsoft items like SQLCe and Open Source libraries like NHibernate. The list of available libraries looked to be very long. The Package Manager also brings down all dependencies required to support requested libraries. The package manager is available as a developer preview on CodePlex.

ASP.NET MVC 3/Razor View Engine

A beta release of MVC is now available that includes, among other things, an update to the Razor View Engine. Using this view engine to show your markup pages in Visual Studio cleans up your markup files by no longer displaying or requiring the <% %> tags. The resulting markup is much easier to read.

This is a very fun presentation, you should really check it out at

Letters - We Get Letters!

I'm always in a good mood when I get to this section, because it's at the end of the issue!

RW from MD points out - Just a small nitpick to an otherwise stellar newsletter. POCO == "Plain Old CLR Object" not "Plain Old C# Objects".

Since I quoted this directly from the Microsoft presenter I decided I better dig deeper. I Googled POCO and found out that it is actually a 70's country rock band whose many hits include Crazy Love. I then used a "decision engine" and determined that, while C# Object does have some mentions, Plain Old CLR Objects is indeed the overwhelming interpretation. Thanks for embarrassing the teacher RW, watch your back.

FM from VA writes - Great write-up Biff. Well done!

Are you kidding? No way I don't print that letter!

?? from ?? rejoices - No registry in the cloud?!? Ding dong the witch is dead, the witch is dead!!!! Or is there a cloud-based reprise coming? That would be so Msft - snatch defeat from the jaws of victory.

Determining the author of the above letter is left as an exercise for the reader.

MA from VA ventures - ...while I agree with your take on Steve B, I actually thought he was pretty sedate compared to normal.

Yes, if he had been at his full-throated peak at 9:00 am he would have destroyed all the hung-over traveling geeks here at the conference.

If you have anything you want to say, any technical questions or anything comment that gives me the opportunity to make a witty retort, send your mail to


Tomorrow is the annual wrap up issue and editorial, see you then,

Archivist, Biff's PDC Newsletter