Architecture and Design

1 Comment

The Microsoft Enterprise Library has always been one of the most popular things to come out of the patterns & practices team. Yesterday p&p reached a major milestone by releasing version 5.0 of EntLib.

The improvements are too numerous to sum up here, but let me mention one: this release has full .NET 3.5 SP1 and .NET 4 compatibility and works great from both Visual Studio 2008 SP1 and Visual Studio 2010 RTM.

Full details can be found in Grigori Melnik’s blog post on this release. Or you can go straight to the download page or the documentation.

A couple of months ago I received a license for NDepend to evaluate its usefulness. I was already convinced that NDepend is a very useful tool. But up to now, I hadn’t put NDepend to good use in a way that I could blog about it.

Today I decided to bite the bullet and put my own pet project FlickrMetadataSynchr up for analysis. Its source code is available on CodePlex.

NDepend analyses managed code for several quality aspects, like cyclomatic complexity, coupling and unused code. In a way it resembles FxCop, but it also does a lot more in terms of reporting. NDepend also is a lot more flexible in letting you query your code base. For this it uses its own SQL variant called Code Query Language (CQL). For example, you could enter this query into the tool

SELECT METHODS WHERE NbLinesOfCode > 30 AND IsPublic

and NDepend will show you all public methods whose number of lines of code exceeds 30.

Just by using the standard settings, NDepend gives you truckloads of information that point to areas with potential code smell. The report has inline comments that explain why it selects stuff and points out possible false positives for which it is okay to ignore the warning.

You can find my NDepend results here if you want to see what such a report looks like.

Starting with those results from top to bottom, I started refactoring my code to improve the quality. For example, splitting up methods to:

  • Reduce cyclomatic complexity
  • Reduce the number of IL instructions in a method
  • Reduce the number of local variables in a method
  • Increase the comment to code ratio

This should increase maintainability of the code.

Go check out this tool if you are interested in improving the quality of your .NET code or if you are tasked with reviewing somebody else’s code.

1 Comment

Microsoft used the keynote in the SOA & Business Process Conference in Redmond to present its vision on the future of Service Oriented Architecture on the Microsoft platform. That vision and the wave of technology that will come with it, is codenamed "Oslo".

MVP Charles Young has a solid write up in a blog post called "Microsoft 'Oslo' - the vNext SOA platform". No need to repeat all that here.

Long time Microsoft watcher Mary Jo Foley is very critical in her post called "Microsoft talks SOA futures but not dates". Mary Jo ends with "Microsoft has been struggling to prove to the market that it has a real SOA strategy. While the Redmondians are talking the right talk, the company is still a ways away from walking the SOA walk. Will customers wait or run off with other SOA vendors before Microsoft rolls out more than just a piecemeal SOA strategy?"

"Oslo" is obviously a Grand Vision. It will take a couple of years before this next wave of Microsoft technologies will ship. I thought that after the Longhorn reset/WinFX debacle and the "Whidbey" delays, Microsoft would not attempt to align so many technologies again in the future. But it is! "Oslo" comprises of at least:

  • BizTalk Server "6"
  • Visual Studio "10"
  • .NET Framework "4"
  • Systems Center "5"
  • BizTalk Services "1"

Some of the stuff presented reminded me of the grand WinFX, especially WinFS, vision that Microsoft presented at PDC03. We all know that WinFS never RTM-ed, despite enormous effort (many, many man years) put into it by Microsoft. Especially the term "Universal Editor" for the "Oslo" integrated modeling tool gave me the creeps. Sounds too much like: One tool to rules them all. One tool that spans the entire application development lifecycle: from its inception to its deployment.

Here are some screenshots from the new "Universal Editor" modeling tool that was demoed during the keynote:

Microsoft Oslo Universal Editor

Microsoft Oslo Server List

Microsoft Oslo Application Verifier

If you are interested in the history of LINQ to SQL and how it works internally, go watch Charlie Calvert's video with Matt Warren and Luca Bolognese.

The first 30 minutes of this video are primarily about the internals. The last 10 minutes focus on the history of LINQ to SQL and how it relates to its "predecessors" Cω  and ObjectSpaces. Matt and Luca also tell how Erik Meijer and Anders Hejlsberg got involved.

Related posts on this blog:

Back in January 2006 I wrote a blog post about a way to add input validation to declarative query string parameters in ASP.NET 2.0.

This involved adding code to the code-behind of each ASP.NET page to hook an event handler. This quickly becomes tedious if you have a lot of pages.

Will Shaver has come up with a better approach. He derives a custom class ValidatedQueryStringParameter from the ASP.NET class QueryStringParameter.

Check out the download on his blog post. It contains a more complete ValidatedQueryStringParameter class that supports other types besides Int32 like DateTime and Boolean. The QueryStringParameter already supports a Type property (of type TypeCode) to specify the type for the value of the parameter, so you can use it from markup like so:

<cc:ValidatedQueryStringParameter Name="CategoryId" QueryStringField="CategoryId" DefaultValue="0" Type="Int32" />

1 Comment

Martin Fowler notices a trend: interest in the .NET platform is declining. Ruby is all the rage. He has some recommendations for Microsoft on how to better collaborate with the community instead of going its own way. Martin noticed how Microsoft created its own unit testing variant that is incompatible with NUnit.

Change is visible in some parts of Microsoft, for example Microsoft is embracing dynamic languages, but boats the size of aircraft carries can only slowly change course. There are no clear signs from upper management at Microsoft that they are indeed changing course. The recent threats against the open source community over infringement on software patents seem to indicate that the old school closed-source thinking still has big strongholds within Microsoft.

Google is about to set a standard for offline storage for web applications with Google Gears. Even better, it's open source. Does Microsoft have the guts to embrace this technology instead of creating its own variant? I doubt it.

I am still pretty excited about the .NET platform. Especially about the LINQ wave of technologies coming with .NET Framework 3.5 and Silverlight. But I am also thinking about looking into Ruby on Rails more and more.

Not many Microsoft employees dare to publicly refer to WinFS as a black hole. Matt Warren does in this blog post. He gives us great insight into the origin of LINQ to SQL and how it managed to survive. He ends with:

So, for the sake of LINQ and the customer in general, we took up the OR/M torch officially, announcing our intention internally and starting the political nightmare that became my life for the next three years.

I briefly talked with Matt at PDC05. It was pretty clear already that he had had a big role in the development of LINQ to SQL even though the public presentation was done by Anders Hejlsberg. His blog is pretty quiet, but Matt is much more active on the MSDN Forums answering questions about LINQ to SQL.

1 Comment

Today, I wanted to continue working on my FlickrMetadataSynchr tool after a break of a month or so. This project uses SaaS in the form of a hosted Team Foundation Server by Microsoft for source control and work item tracking. This SaaS is called CodePlex

Team Foundation Server is known to be a very robust source control system that is based on SQL Server 2005. You can cluster the database tier, you can have hot standby for the application tier, etc.

Yet, Microsoft was able to corrupt the source control database and not have a proper backup schema in place. I.e., they thought they were making backups of the database, yet they weren't.

That will teach me not to trust a third party with my precious data. So based on my current experiences I don't trust Software as a Service (SaaS).

Even worse. Three weeks after the fact, Microsoft still cannot tell if the source control data will ever be restored. At some point you just have to admit you screwed up and say that nothing can be done about it anymore.

Luckily, I still have the latest version of my sources stored locally. But it is the nature of an integrated source control and work item tracking system that you can't keep a full local backup of the state of the system. If Microsoft (or another vendor) screws up you loose a lot of historic data.

Another SaaS that I have become to depend on quite heavily is Gmail. Considering the perpetual beta status of Google Mail, I have never fully trusted them to keep my data safe from disaster. I am very diligent in backing up my mail locally in Outlook PST files using the POP3 access that Gmail provides.

Do you trust SaaS?

1 Comment

I just came accross this gem by Paul Stovell:

Now, although I don’t really know anything about BizTalk, I do know that BizTalk is well-known as an enterprise-grade middleware product. I think that this is due to the fact that only Enterprises (with a capital E) can make custom software development such an expensive process that BizTalk is actually a cheap alternative :)

Is he joking or is he dead serious?

1 Comment

Some people use hyperbole to refer to the disclosure of Silverlight and CoreCLR by Microsoft at MIX07. April 30, 2007 has been called the day that will be remembered as the day that Microsoft "rebooted the web".

This might be true in more than one way. I was just reading the Silverlight SDK and was struck by a feeling of deja-vu:

<TextBlock FontFamily="Arial" Width="400" Text="Sample text formatting runs">
  <LineBreak/> 
  <Run Foreground="Maroon" FontFamily="Courier New" FontSize="24">Courier New 24</Run>
  <LineBreak/>
  <Run Foreground="Teal" FontFamily="Times New Roman" FontSize="18" FontStyle="Italic">Times New Roman Italic 18</Run>
  <LineBreak/>
  <Run Foreground="SteelBlue" FontFamily="Verdana" FontSize="14" FontWeight="Bold">Verdana Bold 14</Run>
</TextBlock>

Doesn't it feel like FONT tags all over again to you too?

This is not revolutionizing the web, this is indeed rebooting the web. Just after text on the web has been semantically liberated from FONT and TABLE tags by judicious use of CSS, we are going back to the future...

PS: Although there is extremely tight coupling between text and layout in this piece of XAML, it is still a much better situation than text locked up in .swf files. At least it is indexable by search engines. Hopefully, Microsoft is just going after the Flash market and doesn't lure us into putting all text inside Silverlight controls leaving the (X)HTML page as just an otherwise empty shell around such controls.

PS2: Here is another commentary by someone who sees some downsides to this new "rich" web as well.