Hello 2.0

This past week we saw the final bits of SQL Server 2005 and Visual Studio 2005 get shipped up to MSDN Subscriber Downloads. Next week we'll see the official launch of these same products to the rest of the world, ushered in with a rolling thunder of launch events and parties stretching into the rest of the month and beyond. Microsoft does a great job of fostering community with events like this.

Technically there is a lot to like about the updates to the platform and I share most of Joel's top picks. I've been building applications, consulting and teaching developers on this platform for 4 years now and it feels quite legacy, if not common place, to me now. However, in many peoples' eyes, this becomes a critical moment in time: .NET is no longer a 1.0 product. Of course I'm speaking about groups who are not developing anything significant in .NET today, and with this maturity milestone, allows them into this “new“ world.

We've been watching the adoption and market maturity of .NET closely for the past few years, and a bit to my surprise I'm starting to see a lot of groups come to .NET for the very first time with 2.0.

This coming Tuesday I have the great pleasure of being involved in the ushering in of this new era at the Toronto launch where we are expecting between 3,000 and 4,000 developers and IT professionals come together. Early statistics are showing that somewhere between 35-50% of these folks are new to .NET. Similar events are taking place all over the world during this week and stretching out into December and beyond. For Canada, Toronto is just the first stop in a long list of cities from coast to coast. Personally, I'll be presenting at Toronto, Ottawa, Vancouver, Montreal, Quebec City and Halifax.

The overwhelming registration statics tics in all cities tells me two things: Firstly that .NET 2.0 is going to be adopted very quickly. Secondly, and more importantly, is that the software development industry in Canada is vibrantly growing and that indeed....Software Matters!

Consider two things:

  • Software costs a lot of money to design, build, test and deploy. Much more than it should.
  • Software projects fail at an alarming rate. Failure can be defined as any of the following: Late, Over Budget, Under Functionality, Buggy, Doesn't meet requirements.

Yet despite these two glaring issues, the business value of software is so compelling, that people are willing to keep investing in building software at increasing rates.

And then there is Visual Studio and SQL Server 2005:

  • One of ASP.NET 2.0's design goals was to reduce the number of lines of code in a typical application by over 50%.
  • SQL Server 2005 has been enhanced to be more reliable and secure, while at the same time bringing the 4GL productivity associated with C#, VB.NET and the .NET Framework into the database engine itself.
  • Visual Studio Team System 2005 was built from the ground up to help project's stay on track by integrating developers, architects, testers, project managers and other stakeholders into a common extensible repository known as Team Foundation Server.

Coincidence? I hope not ;)

VS 2005 Launch Events

Next week, I'm going to be a cabana boy at the VS2005/SQL2005/BizTalk2006 launch events in Toronto and Ottawa. It should be an interesting experience. I'm looking forward to finding out the areas of interest for most people. I've been pretty much immersed in VS2005 for so long, that I almost forget what's new. This should be a nice chance to get caught up with reality.

If you've already made plans to attend, you might want to check out this post from Mark Relph about a 'hidden' contest. If you haven't made plans, there is still room to register in Toronto. The Ottawa event is currently waitlisted. Up-to-date information can be found at the official Canadian Launch Site.

RTM Version of VB Linq

For those of you that think the bleeding edge is not sharp enough, the bits that include the LINQ preview have been redone for the final version of Visual Studio. You can get it here. Personally, I think you should at least let the code cool before working examples of the next version of a language is available, but what do I know.

Developers, start your downloads

If the noise rising up from the blogosphere hasn't reached you yet, Visual Studio 2005 and SQL Server 2005 are now available for download for MSDN subscribers. This would be the 'real' versions as opposed to the beta/CTPs that we've been working with to this point. Also, .NET 2.0 Framework is available at www.microsoft.com/downloads, so that the beautiful VS2005 apps can be deployed to non-development machines.

Big day, to say the least. And T-minus 9 hours before both downloads have finished for me. ;)


Well Snippets are so easy it doesn't make sense not to create them.

I am working on a VB.net 2005 windows application. This client has a very well defined framework. So implementing some feature of the framework is often a matter of finding an example of it in another part of the code then copy and paste. This application was started in VS 2003 and this is primarily what we did. In the beginning we had templates but no one ever wants to keep them up to date as the framework evolves.

Now we have migrated to VS 2005, it's time to take advantage of snippets. So I thought I should try making some, see if it's worth the effort. I was shocked at how easy it is. Let me give you an example: We have a common IU for all forms that display what we define as a document (Order, Product, Customer)

 If you have a piece of code to write that is common in your application. You find a sample of the code in another object. You copy it and paste it into your own object then change the names to suite your object. If you take a few minutes and create a code snippet from this the next time it will be that much faster. The time it takes to create the snippet, you will get back the next time you use it.

  • There will be no looking for it in another object.
  • There will be no removing of the extra stuff from the other example.
  • It will be easier to change the names in the new code.

So here is what I did.

First of all to organize your snippets just create a directory structure to store them in. For example in this application there are 4 distinct object types. Representing different layers. This is a windows application therefore we have Windows Forms, Business Objects, Business Entities and Data Access. Therefore I divided the snippets into this directory structure.

    Windows Form
    Business Object
    Business Entity
    Data Access

Now that we have the directory structure all you have to do is open Visual Studio 2005 and select the menu item Tools |Code Snippet Manager... This dialog is a bit confusing at first there is an add and an import button. Import is for importing a single snippet into an existing Folder. Add allows you to add a directory of snippets all at once. So We'll use the add button to add your folder to snippets. The folder names show up in VS when you select the Snippets so choose them carefully. Even if you don't have snippets for each object type yet add the folder anyway. They won't show up until you put snippets in them.

Creating a Snippet

Now lets create a snippet to add to our folders. Snippets are just an XML file. If you like writing XML as much as I do then you will want to find a snippet editor :) . I downloaded a couple but only installed one. I had every intension of trying out a few of them but this one was so easy to use that I had created about 10 snippets before I realized I was still using the first snippet editor. The one I am using is called snippy it's one of the Power toys for Visual Studio 8.


How to use Snippy

First you enter some basic information like the name of the snippet a description of it and your name. The shortcut can be used by the developer to jump straight to this snippet instead of going through the snippet selector.

Then you select the type of snippet. Expansion, Surrounds With, or Refactoring. I have only tried Expansion so far. So that is what we will continue on with. :)


Enter any name spaces you need to include for the code being added.


Now for the code. You have to select the language (C#, VB, J# or XML ) and kind of code you are entering. Then paste the code in. Anything that you want the user to replace at run time just enter a keyword with dollar signs around it. In my example above the object we are creating will have a name (ie: Customer, Order, Product) so I used the keyword object with dollar signs around it where ever I want to replace the ObjectName in the code. When the snippet is inserted into the code the user will be able to tab through the code changing any of the items you have identified as $object$.


Now for the Literals and Objects this is where you create those place holders mentioned in the code section. Click the add button and you can add a literal for anything you put in the code that the user should replace. The ID must be the same as the name you surrounded with dollar signs.

How simple is that?

Toronto Code Camp Registration Opens

The rumours have been swirling. Now the truth is out.

On Sat. Jan 14, there will be a Toronto Code Camp. You can register/find more infomation/hang out at http://www.torontocodecamp.com/

If you're a developer looking for in-depth content from the people who know (that would be other developers), then the code camp is the place to be. If you're a developer that has in-depth content that other developers could use, this is you're chance to shine. Regardless, it will be a blast. Clear your schedule now to be there.

The end of Begin/End

While on my way back from the MVP Summit, I was playing around with some of the things I had discovered about VS 2005. I mean, if I was going to drip geekiness for the entire conference, why not extend it to the absolute limit. And what I found was something mildly disturbing.

A pet peeve of mine for a while has been how easy it is to make an asynchronous Web service call. Whether the caller knows it or now, that call actually makes your application multi-threaded. For the simplest case, that’s fine. But when you’re making the call from a Windows form application and need to update the user interface with the results of the Web method call, you are getting into an area of complexity that’s more complicated than you realize. Ask any decent developer what the hardest time of bug to crack is and invariably you’ll get ‘race conditions’, ‘deadlocks’ or just the generic ‘multiple threads’ back as the answer. And you have entered that realm unknowingly.

For VS 2005, Microsoft took my complaint and said ‘hey…if updating the UI is soooooo hard, we should make it easier’. Not what I had in mind, trust me. Ask me about a /nomultithread default compiler switch and you’ll be closer. So now instead of calling BeginHelloWorld and EndHelloWorld, it is possible to call HelloWorldAsync and create an event handler for HelloWorldCompleted. Yes, it’s a familiar model. And, as it turns out, HelloWorldCompleted actually fires on the main UI thread, so that ugly MethodInvoker stuff no longer needs to be understood.

But along with changing this asynchronous model, Microsoft also eliminated the Begin/End versions of the methods. Which means if you need to do something like a fork/join pattern, you can’t. Just so that we’re clear, a fork/join would have previously consisted of:

  IAsyncResult ar = ws.BeginHelloWorld(null, null);

  // Do some stuff in parallel with the web service call

  string result = ws.EndHelloWorld(ar);

Because of how EndHelloWorld works, the main thread will block until the background thread has completed. And if the background thread finishes first, processing will continue normally. This is a very common approach if you’re web page were to fire off an asynchronous call to a Web service and wanted to include the results on a page being returned to the client.

As I was saying, since the Begin/End methods are no longer included in the proxy class, this pattern (at least as I have outlined it) is no longer possible. And to replicate the pattern using the event handler model is non-trivial. So my solution was to take the class generated by WSDL (or by adding a Web reference) and putting back in the Begin/End methods that I need. The basic structure is:

  public IAsyncResult BeginHelloWorld(AsyncCallback callback, object asyncState)
   return this.BeginInvoke("HelloWorld", new object[0], callback, asyncState);

  public string EndHelloWorld(IAsyncResult ar)
   object[] results = this.EndInvoke(ar);
   return ((string)(results[0]));

The second parameter on the BeginInvoke call is an array of objects representing the parameters to HelloWorld, so if you’re doing this for a method that takes parameters, you’ll need to change the dimension of the object array and initialize it appropriately.


Atlas for VS 2005 Release Candidate

It looks like the version of Atlas that is capable of running with the VS 2005 release candidate is being...er...released. The link, from what I can see, is here or here. If it doesn't work, keep trying. The page has been alternating between available and missing.

Get it while it's hot.

Productivity tip of the day

If you have ever read my blog you know I love IDE tips that make me more productive. I learned a cool new productivity tip for Visual Studio 2005 today. This is just another great benefit to paired programming. Thanks for the tip Eugene.

Tip of the day:  If you have a file open in VS 2005 you can quickly close it by simply clicking on it with the wheel of your mouse. That's right a wheel click. Just put your mouse over the tab of the file you want to close and click the wheel on your mouse.

You will also notice some new menu items on the context menu if you right click on the file tab. Check these out.

  • Close All But This - Close all open files but this one.
  • Copy Full Path - Copies the location path of this file to the clipboard.
  • Open Containing Folder - Opens file explorer to the folder containing this file.

Microsoft LINQ Resources for September 20th

Community Thoughts

  • Werner Moise has been “reflecting” on LINQ and the more time he spends, the more he's realizing “how well thought out and practical it is”. He has some excellent points.
  • Dinesh wants to know how you feel about attributed-based O/R mapping vs. external XML Files. He also talks about the connected vs. disconnected nature of DLinq. Also, here is the code from his DLinq demo at PDC.
  • Jomo Fisher shows how to create a custom aggregate function in LINQ using extension methods. Sweet, but it don't work for DLinq, but maybe then you want to look at User Defined Types and Aggregates in Yukon/SQL Server 2005. Oh man, this is going to take some architectural distillation.
  • Jon Galloway is scared by code maintainability problems introduced by DLinq. Jon and I share a common PowerBuilder background, where you could put SQL right inside your PowerScript (not unlike Progress either). This is not really a DLinq problem, but a code separation, high cohesion-loose coupling problem. The answer back in the PowerBuilder day was to put all your data access in datawindows. The .NET answer today would be componentized DataAdapters or DataReaders, but we still see the bad practice of people intermingling data access code in other areas of their application. But perhaps maybe DLinq does make this a slippery slope. Maybe we should all just stick to TableAdapters - yikes!






What am I missing? Drop me a line on this blog. I'm heading out next week to a VB Software Design Review and the MVP Summit in Redmond, just because there isn't enough new technology in my life these days.