blogs.conchango.com

welcome to the conchango blogging site
Welcome to blogs.conchango.com Sign in | Join | Help
in Search

Howard van Rooijen's Blog

  • Microsoft Source Analysis for C# + ReSharper = Real-time Source Analysis

    I've worked on a couple of projects for Microsoft UK - one of the many great aspects of those projects was being able to use some very cool internal tools; my two favourites being the pre-cursors to Team Foundation Server (Product Studio + Source Depot) and StyleCop - which is to source code what FxCop is to binaries.

    StyleCop quickly found a very special place in my heart - mainly because it soothed my coding standards / consistency / best practice OCD. I'm a fervent believer in coding standards - not only for the obvious reasons of consistency and maintainability - but mainly because I like the aesthetics of elegant code. It's hard to describe without sounding like a kook, but I find code formatting and refactoring quite soothing while I'm trying to solve bigger business logic problems - it helps me get into the zone.  Consistently well formatted code sits well in my visuospatial sketchpad - it forms visual patterns that are easy to recognise when scanning code - an upshot of which is that it's very easy to see out of place (bad / sloppy) code and thus spot where bugs are likely to appear.

    Using StyleCop meant an end to all the stupid arguments I used to get embroiled in whenever a new developer would start on a project; even though there was obviously a standard in place that the team was adhering to, the new developer would insist on coding "m_" styleee because that's how they'd always coded. StyleCop became the H-Bomb argument killer - if you didn't conform to the standard, you would break the build. With one less thing to worry about, your team can focus on the much more important issue of delivering business value to the customer.

    The genius behind StyleCop is Jason Allor - he's done an awesome job by not only creating a tool which the whole C# community has been crying out for, but also achieved the amazing feat of getting buy-in from (or wrangling) a large number the internal MS teams to adopt StyleCop; hopefully this is a win-win situation as it helps make the products better, but also if Microsoft continues to push the envelope with it's transparency - we should all benefit.

    After many people begged for it to be released externally, StyleCop has been rebranded as Microsoft Source Analysis for C# (MSAFC) and released on the MSDN Code Gallery, Jason has also created a Source Analysis blog where documentation, hints, tips and trivia will live. The first release has MSBuild integration and wonderfully Eugene Zakhareyev has already created a TFS Check-In Policy 

    One aspect that already amuses me is the number of people who are regurgitating many of the internal arguments that happened during StyleCop's infancy - "what do you mean 'use spaces instead of tabs'! No way - spaces are evil" - or the number of people who have raised issues because they want to be able to selectively turn rules on and off. Duh. I really hope Jason has copies of those flame-war threads so he can publish them onto the blog so that people understand the reasoning behind the rules - if only to highlight the point that if 1000's of Microsoft Product Team Developers can agree - then persuading your development team to adopt the rules should be easy.

    When time came to leave those Microsoft UK internal projects - the hardest part was going through StyleCop withdrawal. When I went to the Team System SDR in 2004 I begged and pleaded like a fanatic to have StyleCop included in the product - but it was not to happen. I started to look around the web for alternative tools - but there were only pale imitations. So I started to do a little research into what it would take to write my own.

    I soon discovered that I was no-where near hardcore enough to write my own C# parser - even worse, many of the open source ones only worked for .NET 1 / 1.1 and had not been updated to support 2.0 with generics support - and as Conchango deals with cutting edge .NET projects we need .NET 3.5 language features to be supported (although I have just discovered LINQ over C# - which looks like it could do the trick!). I started looking at DXCore but then on a tangent started to see if there was anyway to extend ReSharper via their Open API. There wasn't a huge amount of documentation - but I managed to piece together what was required from a few blog posts and samples. I wanted to create a tool that had the features of StyleCop and the elegance of Resharper - namely that I wanted real-time syntax checking - so it's slightly bittersweet that Microsoft Source Analysis for C# has been released just as I had completed a working prototype!

    So last night - I took my abandoned ReSharper plug-in code and decided to try to integrate it with MSAFC. Below is a screenshot of the result. It's still a little buggy - but hopefully over the next few days I can fix the major issues and release a version to the web.

    realtime-source-analysis

  • Configure MIME Type for Silverlight 2.0 in IIS

    I helped Richard Griffin deploy a Silverlight 2.0 DeepZoom demo he had put together at the end of last week on an internal server. We deployed the application inside a virtual directory in IIS but the application would not load in the browser. Using Fiddler it became apparent that the main Silverlight application was requesting a .xap file from the ClientBin directory but this was coming back as a 404. IIS wont serve unknown filetypes, in order for .XAP files to be served by IIS you need to add a new MIME Type:

    Extension: .xap
    Mime Type: application/x-silverlight-app

  • Continuous Education++

    While catching up on long overdue flagged posts to read - I spotted a familiar meme on becoming a better developer – I wrote about Continuous Education almost 2 years and it’s nice to see that this topic keeps reappearing. I’ve updated my bubble graph of the technologies to include those that I’ve used over the last 12 months and have also added training courses and events I’ve attended:

    ContinuousDevelopmentPlusOn

    Apart from the foray into WPF development in late 2006 / early 2007 and a little dabbling with Silverlight 1.1 post Mix 07 – I’ve been involved predominantly in the RIA space. It was a bit of a mental shift working on several smaller projects in 2007 as until Christmas 2006, I had been working for the same client, creating a number of products based on a shared platform for almost 2 years.

    Another change that’s happened in the last 18 months is that I took on the role of a Technology Coach responsible for the career development and appraisals of a number of developers within Conchango. Performing this function has given me a new perspective Continuous Education; one thing that Agile Methodologies has taught me is the power of a feedback loop – the tighter the feedback loop the greater your ability to inspect and adjust; this can work really well if you know the career aspirations of the people in your team and you have the mechanism (i.e. an iteration) where you can let those people learn and grow.

    One topic I've been spending a lot of time thinking about over the last year is "how do you hone a development team into a state of hyperproductivity?" If you assume that the foundation of the team is an Agile process with iterations and a feedback loop (retrospective), what other facets do the team need? At the moment I'm convinced it's confidence or to be more specific, fearlessness, the state of mind you can achieve when you have confidence that you know what you are doing, confidence that you can make a change and you know the impact and ramifications of that change. Team velocity can be severely impaired by the fact that a development team is intimidated by the codebase, either because it is very large, complex or mainly unknown to them – they fear making changes because they don’t know what the cost of that change would be.

    Two vectors that I believe helps developers into the fearless state of mind are test coverage and refactoring tools. Empowering the team with Resharper and spending time teaching them how to really use it means that they are suddenly much more in control of the codebase than before; they can easily see the interconnectedness of the code; renaming, moving, deleting cleaning and extending the code has suddenly become a simple if not trivial task. A feature like Resharper's "find usages" give a great hint as the the cost of a change. But the real confidence only comes with good test coverage (integration and / or unit). These two vectors  should give them enough confidence to put them in the state of mind that they could be a bit more fearless, which tends to means that in time they start becoming more independent, self managing members of the team – which is when they are truly useful and truly productive. Ben Watson has a nice post called 6 Ways to Increase Your Confidence As You Code.

    I also tend to read a lot - I subscribe to around 70 blogs (I use Newsgator Inbox (now free!) and Outlooks' search folders to filter for topics I'm interested - the rest get perused on train journeys), I'm also quite an avid consumer of books, below are the ones I’ve purchased and read in the last 12 months:

    AgileWebDevelopmentRails Agile Web Development with Rails
    RubyForRails Ruby for Rails: Ruby Techniques for Rails Developers
    RailsRecipies Rails Recipes
    ApplicationPlusCode Applications = Code + Markup: A Guide to the Microsoft Windows Presentation Foundation
    DreamingInCode Dreaming in Code: Two Dozen Programmers, Three Years, 4,732 Bugs, and One Quest for Transcendent Software
    WPFUnleashed Windows Presentation Foundation Unleashed
    WCFUnleashed Windows Communication Foundation Unleashed
    ExpressionBlendBible Expression Blend Bible
    IntroducingASPNETAJAX Introducing Microsoft ASP.NET AJAX
    IntroducingLINQ Introducing Microsoft LINQ
    51EC77B5AbL__SS500_ Herding Cats: A Primer for Programmers Who Lead Programmers
    4104N6ME70L__SS500_ Getting Things Done: The Art of Stress-free Productivity
    51G9GF8VQML__SS500_ Software Estimation: The Black Art Demystified

    deploying-net-apps-msbuild-clickonce

    Deploying.NET Applications: Learning MSBuilder and Clickonce
    51ZfuTVoX0L__SS500_ xUnit Test Patterns: Refactoring Test Code: Refactoring Test Code
    41WUmFs2vZL__SS500_ Regular Expression Pocket Reference
    51QQidWjIQL__SS500_ Domain-driven Design: Tackling Complexity in the Heart of Software
    51PowJFAeAL__SS500_

    Domain Specific Development with Visual Studio DSL Tools

  • Custom Chalk Extensions for Graffiti CMS

    Telligent, who produce Community Server (which is the current http://blogs.conchango.com/ blogging platform) have just released Graffiti CMS v1.0 - a light weight, simple to use Content Management System. There was a slight overreaction by the WordPress community to Telligent's Google AdSense campaign - but luckily things seemed to have calmed down a little, especially as Graffiti seems be surrounded by a growing good vibe and is building a solid community.

    I've been looking at using Graffiti as the CMS for a little side project and have been incredibly impressed by its great usability, simplicity (you really can install it in under two minutes) powerful extensibility points and timely support from Telligent on their forums. The theming engine - called Chalk is based on the Castle Projects' cut of NVelocity and is a joy to use; it's certainly a nice antidote to the overheads and complexities of developing using ASP.NET WebForms.

    The product has been built with extensibility  at the core - so any features that are not included out of the box are trivial to add. A few Graffiti Extension Projects have sprung up already, hopefully these will grow and grow in the future.  I've created a CodePlex project called ChalkExtensions which contains the custom Chalk extensions I've written for my pet project.

    So far the extensions are:

    • public PostCollection GetAllPostsForCategory(string categoryName)
    • public PostCollection SortPostsAscending(PostCollection posts, string propertyName)
    • public PostCollection SortPostsDescending(PostCollection posts, string propertyName)
    • public PostCollection Randomize(PostCollection original, int numberOfPosts)
    • public PostCollection GetRandomPostsForCategory(string categoryName, int numberOfPosts)

    Using the extensions is simply a case of compiling the code, dropping the dll into Graffiti's \bin folder and then from within any of your .view files you can simply call the extensions using the $ChalkExtensions syntax. For example, pulling back 3 random posts from the "Events" and rendering them into content blocks can be done as follows:

    #set($latestEventsPosts = $ChalkExtensions.GetRandomPostsForCategory("Events", 3))
    #foreach($post in $latestEventsPosts)
       <div class="contenttextblock">
          <h3><a href="$post.Url">$post.Title</a></h3>
          <p>$post.Excerpt("", "" , "[read more]", 300)</p>
       </div>
    #end

  • Attach to Web Server Macro for Visual Studio

    Last week I was doing a lot of ASP.NET debugging – tracing through Microsoft AJAX web service calls and was getting a little frustrated of the time lag for starting a site in debug mode; I remembered a Visual Studio macro for attaching to the worker process and that I had rewritten in a couple of years ago to attach to multiple worker processes, in case you were running multiple sites (i.e. a web services layer and an application layer) on either Windows XP (aspnet_wp.exe) or Windows Server 2003 (w3wp.exe). Below is the source for the macro – I've tested it on Visual Studio Orcas Beta 1.

    Imports System
    Imports EnvDTE80
    Imports System.Diagnostics

    Public
    Module AttachToWebServer

       Public Sub AttachToWebServer()

          Dim AspNetWp As String = "aspnet_wp.exe"
          Dim W3WP As String = "w3wp.exe"

          If Not (AttachToProcess(AspNetWp)) Then
             
    If Not AttachToProcess(W3WP) Then
                
    System.Windows.Forms.MessageBox.Show(String.Format("Process {0} or {1} Cannot Be Found", AspNetWp, W3WP), "Attach To Web Server Macro")
            
    End If
         
    End If

       End Sub

       Public Function AttachToProcess(ByVal ProcessName As String) As Boolean

         
    Dim Processes As EnvDTE.Processes = DTE.Debugger.LocalProcesses
         
    Dim Process As EnvDTE.Process
         
    Dim ProcessFound As Boolean = False

         
    For Each Process In Processes
            
    If (Process.Name.Substring(Process.Name.LastIndexOf("\") + 1) = ProcessName) Then
               
    Process.Attach()
               
    ProcessFound = True
            
    End If
         
    Next

          AttachToProcess = ProcessFound

       End Function

    End Module

  • TFS Notification Web Services - Project Template v.1.2

    Over the past few weeks I've been getting more and more messages from people who can't seem to get v1.1 to work with Visual Studio 2005 SP1. Fortuitously for them, a long train delay last night gave me the opportunity to make some fixes that have been long overdue since v1.1 was released almost a year ago.

    Visual Studio Project Template Dialog

    Changes in this release

    • Rebuilt to work with Visual Studio 2005 SP1 and Visual Studio Orcas Beta 1
    • Changed from a Web Project to a C# Project.
    • Slight refactoring of the codebase
    • Updated the EndpointBase class to deserialize the XML message using an XmlReader rather than an XmlDocument.

    Installation

    For Visual Studio 2005:

    • Copy the "TFS Notification Web Services.zip" file to the directory "X:\Documents and Settings\YOUR_USER_NAME\My Documents\Visual Studio 2005\Templates\ProjectTemplates" and then open Visual Studio 2005 and select File > New Projects. From the "My Templates" section select "TFS Notification Web Services"

    For Visual Studio Orcas Beta 1

    • Copy the "TFS Notification Web Services.zip" file to the directory "X:\Documents and Settings\YOUR_USER_NAME\My Documents\Visual Studio Codename Orcas\Templates\ProjectTemplates" and then open Visual Studio Orcas Beta 1 and select File > New Project. From the "My Templates" section select "TFS Notification Web Services"

    For Windows Vista users the path "X:\Documents and Settings\YOUR_USER_NAME\My Documents" should be changed to "C:\Users\YOUR_USER_NAME\Documents"

    You can download the updated Project Template from my ProjectDistributor Workspace.

  • Agile Architecture: Painting by Numbers

    View from Bishops Landing, by Sarah NasbyDuring one of the Open Space sessions I attended at the Scrum Gathering in 2006 I put forward the analogy of "Painting by Numbers" Architecture, which is my take on how Architecture should be handled on an Agile project. The basic premise is that the Architect has the overall vision of how the solution should hang together; what its basic composition should be, what the outline is and what attributes it has; but this view is of a very low fidelity; much like the outline of a "paint by numbers" picture. It's then the team's job to fill in the segments, sprint by sprint – in whatever colour, hue or order they decide upon; they are free to improvise within that segment.

    I've been thinking about writing an exhaustive post on the subject for months, but then last week I watched Dave McKean and Neil Gaiman's extraordinary film MirrorMask. The DVD is packed full of great extras, but there was one that grabbed my attention; a blurry video of a conference Q&A session with the audience, where someone asks Mr McKean about his experiences doing the spectacular Computer Graphics (CG) work for the film. The response was fantastic and is pretty much a crystallisation of my thoughts on the "paint by numbers" scenario. I paraphrase his response below:

    In the studio shooting, it was a nightmare, none of the computers would talk to each other; none of them knew each other or were interested in talking to each other at all.

    So I hired a small team, just 15 people and they did the whole film; they were all kids, fresh out of art school, for almost all of them this was the first job they'd ever done. I thought if I was in their situation, I wouldn't want a usual CG job, which is "you get to do the bubbles" or "you get to do one tiny bit of texture on something", it's so de-compartmentalised you're a bit of a cog in a machine. I thought "if I were doing it" I'd want my own scene, like a short film within the whole; so that was the plan, we had a big meeting, talked through the whole film and we divvied up the scenes between us. It worked mostly, some of them were more interested in animation, some of them were more interested in set-building and texture mapping and things like that, so it crossed over a bit, but generally they got to do their scene.

    I designed things, but I didn't really want to nail everything because I wanted to know what they wanted to do, what their input would be; it was the best of collaboration really, they all got excited by the fact that they would be represented in the film properly; when it got to their section they could say "hey, I did this bit".

    They all came up with wonderful ideas, which expanded from the script in all directions – I always had backup plans in case we ran into problems, of how I knew we could do it, but we almost never needed them. Almost everybody came up with ideas and ways to amplify and exaggerate and elaborate on the ideas and make it bigger and better – it was terrific.

    I was there really to keep everything having "my line" as it were, so it looked like I drew it, and I did all the texture maps for the film, because I feel like that's where my colours and textures really come into it, so I did all that, and then I composited the whole film.

  • A week with Silverlight 1.1

    Richard Griffin, Steven Evans and I spent a week working on a Silverlight demo that Paul Dawson used as part of his ReMix presentation "WPF & Silverlight: A Loaded gun?" although I can't publish the demo yet, I thought it might be useful to go over some of the things we learnt putting it together.

    All three of us have WPF experience; we've read the de facto books and we all worked on Daily Mail eReader project; so a lot of that knowledge was transferable to development in Silverlight. None of us had played with Silverlight when it was in its WPF/e incarnation (but fellow conchango-ite John Rayner did) and although Richard and I have plenty of experience getting our hands dirty with JavaScript, after Mix07, Silverlight 1.1 Alpha was the version we really wanted to get our teeth into. So here are a few of our learnings:

    Ensure you have correct bits installed

    I know this sounds obvious – but if you're an alpha geek who installs all the latest CTPs, it's easy to get out of synch and then spend hours wondering why the project doesn't compile correctly. Follow the official instructions. If you don't want to contaminate your dev machine – create a VPC image and then tune it.

    Also make sure you have the tool you need for testing / debugging / troubleshooting when things go wrong:

    Update Blend 2.0 May CTP to work with Orcas Beta 1

    Blend 2.0 May CTP doesn't integrate with Orcas Beta 1 projects out of the box – you need to create a Blend.exe.config file in the applications directory which updates Blend's MSBuild version to Orcas' version. The full steps are outlined in the Blend 2 May CTP Readme file.

    Use Blend 2.0 May CTP for layout and adding controls

    The build of Cider (the WPF design surface) that ships with Orcas Beta 1 does not support the Silverlight XAML schema yet (thus inside Orcas you always get the "code view" of .XAML files) so unless you want to do layout, animation and custom control addition by hand you'll need to do all of that in Blend.

    One note of caution – Blend sometimes seems to create invalid xmlns directives when referencing external assemblies; the project will compile inside Blend, but not Orcas. Ctrl-Z is your friend in this scenario.

    "Add Silverlight Link" NOT "Add Reference"

    If you have a multi-project solution, one of the peccadilloes of Silverlight emerges – you can't link projects together using the standard "Add Reference" option – you have to use the new "Add Silverlight Link" option instead – otherwise project content (i.e. XAML files, folders and .dlls) are not updated correctly.

    Define your Solution and Project structure

    We knew from the start that we were going to have multiple projects within our solution. We wanted to separate out the website, Silverlight application and Silverlight controls. So we followed the Conchango reference build structure and then added three projects under the "Solutions" folder:

    • ProjectName.App – this contains the Silverlight Application
    • ProjectName.Controls – this contains all the reusable controls such as Buttons, Sliders etc
    • ProjectName.Web – this contains the website which hosts the Silverlight app.

    ProjectName
    +---Main
    ¦ +---Build
    ¦ +---Solutions
    ¦ +---Common
    ¦ +---ReferencedAssemblies
    ¦ +---ProjectName.App
    ¦ ¦ +---Assets
    ¦ ¦ ¦ +---PageName
    ¦ ¦ ¦ +---Music
    ¦ ¦ ¦ +---Video
    ¦ ¦ +---ClientBin
    ¦ ¦ +---Properties
    ¦ +---ProjectName.Controls
    ¦ ¦ +---Assets
    ¦ ¦ +---ClientBin
    ¦ ¦ +---Common
    ¦ ¦ +---Properties
    ¦ +---ProjectName.Web
    ¦ +---App_Code
    ¦ +---App_Data
    ¦ +---Scripts
    ¦ +---Styles
    +---TeamBuildTypes
    +---DEV

    Project.App was linked into ProjectName.Web throught the use of the "Add Silverlight Link" mentioned in the previous tip. Once the Solution is compiled this caused all the contents (Folders, XAML files and .dlls) to be copied into the ProjectName.Web project. So ensure your ProjectName.Web project is clean before you add it to Source Control – otherwise you'll hit problems when you build your project in the future.

    To keep ProjectName.Web as clean of referenced files as possible, we settled on the convention of keeping all images, music and video in a folder called Assets. Because the design of our app is quite graphically intensive we decided to create a folder per XAML Page to contain its graphics.

    Missing basic controls? Turn to the Community...

    Silverlight 1.1 is an Alpha release after all – so much of the RTM functionality is still missing, including many of the intrinsic controls you'd use on a day to day basis (such as Button, TextBox etc). One solution is to use and modify the samples supplied as part of the Silverlight 1.1 Alpha SDK or you could try experimenting with the more extensive Layout System and Controls recently released by Dave Relyea.

    Gather as many samples as you can

    The best way to learn it to check out what everybody else is up to. For the first few weeks after Mix07 samples were a little thin on the ground (oh look! Another rotating rectangle that's clickable!). I found the following links quite useful:

    When copying sample code ensure your Build Actions are correct

    I first fell foul of this issue when I imported the Silverlight 1.1 Alpha SDK controls sample into our ".Controls" project. I selectively imported the files I wanted to use and could not, for the life of me, workout why the Button control would not load and caused a runtime error.

    Because Silverlight 1.1 does not support the WPF style of XAML file / nested partial class code-behind, the workaround is having a XAML file as an embedded resource with the same name as the class file. In the constructor of the class reflection is used to extract the XAML file and instantiate it.

    If you import the files into a project you will lose the Build Action settings which will specify that the XAML files are "Embedded Resource" rather than "SilverlightPage" thus when the class is instantiated the XAML file cannot be retrieved from the Assembly Manifest and the exception will be thrown.

    Add ASP.NET Futures controls to the toolbox

    A new drop of the ASP.NET Futures project was released to coincide with the release of Silverlight 1.1 Alpha. This project adds two ASP.NET server controls; a Media Control which simplifies the hosting of audio and video and a XAML Control which eases the pain of hosting XAML files.

    To add the controls to the Toolbox you need to right click, select "Choose Options", select the ".NET Framework Components" tab, sort the list by Namespace and browse to Microsoft.Web.Preview.UI.Controls and select the "Xaml" and "Media" options. You should now be able to drag and drop the controls onto the page from the toolbar.

    ASP.NET Futures XAML Control has a fundamental bug

    The current implementation of the ASP.NET Futures XAML control causes the same "Click to activate" issue that has affected the Flash community for the past couple of years since the Microsoft / Eolas case. The simplest workaround is not to use the XAML control, as the default method for instantiating the Silverlight plug-in does not cause this behaviour. This issue should be fixed in the next release.

    Enable Silverlight Debugging in Web Projects

    If you are trying to debug your Silverlight application from within a Web Project and for some strange reason none of your breakpoints get hit – ensure that you've selected Silverlight Debugger option in the "Web Project Property Pages > Start Options > Debuggers" section.

    Orcas Web Project Property Pages

    Isolated Storage Quota

    Silverlight 1.1 Alpha allows applications to persist up to 1mb of data locally (similar to Flash's Shared Objects), which allows for much more flexibility for storing data than the 4kb limit for http cookies (think local data cache). There are several good examples of how to implement Isolated Storage in both C# and Managed JavaScript.

  • Mix07

    Yes, along with Andy, Richard, Una, Paul and Mike (and Keni at MEDC) – I'm here in Las Vegas partaking in Mix07 as well. We've just had breakfast and are setting up Twitter accounts before the keynote – so if you're interested in keeping up with what we're doing you can keep an eye on http://twitter.com/HowardvRooijen or if you want to keep up to date with what's happening at Mix 07 in general go to http://twitter.com/mix07/with_friends

  • Debugging an ASP.NET 2.0 AJAX-Enabled Application in Visual Studio 2005 on Windows Vista / IIS 7

    I came across an interesting issue today when I was creating a new ASP.NET AJAX-Enabled Web Application Project in Visual Studio 2005 (with the Visual Studio 2005 SP1 Update for Windows Vista applied) on Windows Vista. After hitting F5 to start the launch the web app in debug mode I received the following error:

       Unable to start debugging on the web server. An authentication error occurred while communicating with the web server. Please see Help for assistance.

    After a little digging, the following steps solved the problem:

    1. Open IIS Manager
    2. Select the virtual directory of the web application
    3. Click "Advanced Settings"
    4. Select the "Application Pool" item in the "Behaviour" category
    5. Change the value from "DefaultAppPool" to "Classic .NET AppPool"
    6. Restart the website to apply the changes.
  • Configuring WCF Services for Unit Testing

    A couple of weeks ago I pinged Paulo for some help about a WCF service I was writing – he solved the problem I was having and replied that he liked the unit testing pattern I was using for starting the WCF service and couldn't believe he didn't think of it. So I thought I'd blog it, just in case anyone else was interested.

    Basically you create a internal ServiceHost wrapper class, which creates a new instance of ServiceHost based on the type of the WCF service you're trying to test; this wrapper class has two static methods exposed: StartService() and StopService() which, starts and stops the ServiceHost instance. If you are using the Visual Studio Unit Testing framework, in your unit test class you call StartService()in the method marked with the [ClassInitialize] attribute and StopService()in the method marked by the [ClassCleanUp] attribute. If you are using MBUnit or NUnit you would use [TestFixtureSetUp] instead of [ClassInitialize] and [TestFixtureTearDown] instead of [ClassCleanUp].

    namespace Conchango.WebTwo.Services.Tests
    {
       using Microsoft.VisualStudio.TestTools.UnitTesting;
      
    using System.ServiceModel;
      
    using Conchango.Services.Resourcing;
      
    using Conchango.Services.Contracts;
      
    using Conchango.WebTwo.CommonTypes.Resourcing;

       [TestClass
       public class ResourcingServiceTests
       {
          /// <summary>
         
    /// Start the Resourcing WCF Service so all subsequent
         
    /// calls made by the unit test use this connection 
          /// </summary>
         
    /// <param name="testContext">Current Test Context</param>
         
    [ClassInitialize()]
         
    public static void ClassInitialize(TestContext testContext)
         
    {
            
    ResourcingServiceHost.StartService();
         
    }

          /// <summary>
         
    /// Shut down the WCF service once all tests have been run
         
    /// </summary>
         
    [ClassCleanup()]
         
    public static void MyClassCleanup()
         
    {
            
    ResourcingServiceHost.StopService();
         
    }

          /// <summary>
         
    /// Search for people called "Howard" at Conchango - expect 2 matches
         
    /// </summary>
         
    [TestMethod]
         
    public void PeopleCalledHowardTest()
         
    {
            
    using (ChannelFactory<IResourcingContract> factory = new ChannelFactory<IResourcingContract>(string.Empty))
            
    {
               
    IResourcingContract client = factory.CreateChannel();
               
    People people = client.GetPeopleByPartialName("Howard");
               
    Assert.AreEqual(2, people.Count);
            
    }
         
    }
       }

       internal class ResourcingServiceHost
      

          internal static ServiceHost Instance = null;
         
         
    internal static void StartService()
         
    {
            
    Instance = new ServiceHost(typeof(ResourcingService));
            
    Instance.Open();
         
    }

          internal static void StopService()
         
    {
            
    if (Instance.State != CommunicationState.Closed)
            
    {
               
    Instance.Close();
            
    }
         
    }
      
    }
    }

    One other point of note; on the line:

    using
    (ChannelFactory<IResourcingContract> factory = new ChannelFactory<IResourcingContract>(string.Empty))

    the string.Empty is required in the ChannelFactory contructor otherwise the following Exception is thrown: "System.InvalidOperationException: The Address property on ChannelFactory.Endpoint was null. The ChannelFactory's Endpoint must have a valid Address specified."

  • Scrum for Team System 1.2 released

    After an immense amount of hard work from Stuart, Colin and Merrick a new version of Scrum for Team System has been released. Version 1.2 of Scrum for Team System contains a number of changes:

    Reports

    • Significant performance improvements compared to the v1.1 reports (we recommend you use the Report Installer to upgrade your existing reports to the latest version – see below).
    • Portal Reports are now hidden from Team Explorer. (The hidden reports may be seen by visiting the Report site and selecting "Show Details")
    • A small "(Hidden) Bug History Chart Small" is available for use in the portal.
    • A "Version" report has been added to aid identification of the version of Scrum for Team System in use.

    Windows Sharepoint Services

    • "Quick links" functionality has now been re-introduced.
    • A "bottom zone" has been added to the default template to allow more flexibility in the customisation of the layout of the Portal.
    • The default portal site for a new Team Project now displays the following reports: Sprint Burndown Chart, Product Burndown Chart, Bug History Chart, Product Cumulative Flow

    Utilities

    • Report Installer (which is used to upgrade the reports in existing team projects) now has the option to completely refresh the report site for a particular team project with the latest reports (by deleting all existing reports in the Team Project before the new ones are installed). Alternatively, individual reports can be overwritten with the latest versions (for example if you have added custom reports that you wish to keep) and the new ones added.

    Process Template

    • No changes since v1.1

    Upgrade process from earlier versions

    • If you are on v1.0 you need to install version 1.2, create a new team project and follow the migration steps to get to v1.2.
    • If you are on v1.1 you need to install version 1.2, run the Report Installer from the AdminUtilities package to update all reports and then customise the existing portal to get to v1.2.

    We've also added a new feature requests section to the forums – so If you have any good ideas, or modifications you'd like to see, you can post your wish list. We've also added a list of training courses we're running over the next few months, in addition to the regular Certified Scrum Master and Agile Estimation and Planning courses we are running a new 2 day workshop on April 16th – "Agile Retrospectives" with Ester Derby and Diane Larson. I was fortunate enough to attend a one day workshop at the Scrum Gathering 2006 and highly recommend it. If you can't make it to the workshop – buy the book – it will transform the way you approach your Sprint Retrospectives.

  • Scrum Gathering / Open Space Technology

    Last November I attended the 2006 Scrum Gathering in Minneapolis along with fellow Conchangoens Colin Bird and Gavyn Dowst. It was a conference like no other I've attended; earlier last year I co-presented a session on Agile Architecture at the Microsoft Architecture Insight Conference with Simon Evans, where to be quite frank, the reception of talking about how two experienced architects had managed to deliver and continued to deliver business value, iteration after iteration, was frosty to say the least and in some cases downright offensive.

    The reception these ideas and experiences received at the Scrum Gathering couldn't have been more different. Instead of being confrontational and pouring on vitriol in order to justify their own job or methodology, attendees of the Gathering were so open minded. More often than not the reaction was "Wow, my experience of doing X was completely different. How did you handle situations like Y?" Ideas were cross-pollinated and people came away with a myriad of new techniques to try.

    There were a couple of things I took away from that conference; firstly that Scrum and Agile Methodologies are really crossing the chasm - large organisations are starting to believe in them and are trying to roll it out in a top down manner (I think the largest number I heard was 700 development teams) with varying degrees of success. Secondly, Scrum causes organisational change and business transformation, more and more practitioners are realising that there needs to be a programme level project for organizational transformation otherwise Agile project teams meet friction where they have to interact with any other part of their organisation, which severely hampers, if not cripples their productivity. The third actually has nothing to do with Scrum or anything Agile - it's actually the technique called "Open Space Technology" (OST) that was used to run the Conference.

    Open Spaces Technology

    Open Space Technology was created in the mid 1980's by Harrison Owen who had spent a year of his life organising an international meeting with over 250 delegates; the overwhelming feedback from the delegates was that they all enjoyed the coffee breaks more than the keynotes because the breaks allowed them to interchange ideas. He was asked to arrange the event again the following year and while pondering if there was a fundamental mechanism for organising a successful conference, he remembered his experience of witnessing tribal meetings in Africa; where the circle is a fundamental form of communal meetings; if people are invited into a circle they will participate and communicate – a circle has no beginning, no end and no hierarchy.

    Conferences run using Open Space Technology are different – there are no keynotes, no panels, and no pre-announced schedule; instead the Open Space Technology relies on self-organisation and is a vibrant mix of order and chaos. It can be used for any type of meeting; from envisioning to conflict resolution and it's been proven to work with 5 – 2000 delegates for 1-3 day conferences.

    Anatomy of an Open Spaces Session

    If you walk into an conference or meeting run using OST you'll probably find yourself in a large room with a circle of chairs in the middle (or if there are lots of delegates it will be a spiral or series of concentric circles of chairs). In the corners of the Room you'll probably see flip charts and on one of the walls you'll probably see a matrix of post it notes – this is called the Agenda Wall. When an Open Space Conference starts the delegates sit on the chairs in the circle. The first person to speak is The Sponsor – who will outline the context for the session and their hopes and expectations. For the Scrum Gathering our theme was "How do we sustain the values and principles of Scrum as we adopt the practices in our organisations?"

    Welcome to Open Space

    Next The Facilitator speaks to the delegates from the centre of the circle; they reiterate the theme and explain the process of Open Space Technology; that the agenda wall is a matrix of times and locations which can be used to host discussion groups:

    Times and Locations

    Anyone can create a discussion group – all they – The Host - have to do, is take an index card, write the title of the discussion on it – assign it to a free time / space slot on the agenda wall and then announce it to the rest of the delegates.

    delegates viewing the agenda wall

    Those who are interested in participating in that discussion should initial the card to signify their interest.

     a close-up of the agenda wall

    The Facilitator also has to and explain and ask the participants to adopt The Principles of Open Space for their discussion groups:

    1.    Whoever comes are the right people
    2.    Whatever happens is the only thing that could have
    3.    When it starts, it starts
    4.    When it's over, it's over (and when it's not over, it's not over)
    5.    The Law of Two Feet – If you are not learning or contributing where you are, use your two feet to take yourself someplace where you can learn or contribute

    Next the circle is disbanded and discussion groups convene in their allocated location, at the allocated time. The Host of a discussion group asks for a volunteer to act as The Note Taker, who captures the conversations on the flipchart while The Host facilitates the discussion. Once the session has ended – it's The Host's responsibility to turn the notes into a more permanent record of the session and so that people who couldn't attend because of a conflicting sessions can have an overview; at the Scrum Gathering we had a dedicated wiki that was used as the permanent record for both Wednesdays and Thursdays sessions – the benefit of this is that it can be opened up to the wider community who could not attend the Open Space; one of the discussion groups Gavyn and I attended was called "The Managers Role in Scrum", hosted by Jens Ostergaard. Since then, the topic has been picked up by Jeff Sutherland and continues to evolve. Another example of this happening is that Gavyn and I ran a session on "Testing in Scrum" although the turn-out was small because we were scheduled against Colin's ridiculously popular "Scaling Scrum" discussion group, some great experiences were shared and ideas were crystallised and were published in Gavyn's series of blog posts "Testing in Agile" parts one, two and three.

    If the event is a multi-day affair then there will be "check-ins" in the morning and afternoon – where new sessions can be added to the agenda wall – this allows new ideas to be spun out of discussion groups and elaborated on. At the end of the event the Space is closed by The Facilitator who invites the attendees to briefly share their thoughts, reflections, experiences or learnings.

    Open Spaces Technology works so well when you're trying to discuss any complex topic, especially when there are passionate people involved. The fact that there is no pre-announced schedule means that as interesting ideas crop up, new discussion groups can be spun up, which allows people to discuss much finer grain topics than are usually discussed in conferences and because of The Law of Two Feet, you only get people who are willing to contribute and so the session are so much more vibrant. I'm hoping that we try and run a Conchango Community Day using Open Space Technology soon.

  • WPF: Blurry UIElements

    If you're writing a WPF application the chances are that you'll run across this little oddity fairly soon. On some monitors UIElements can appear slightly blurry or over anti-aliased, almost as if ClearType were over-compensating. The solution is to set the SnapsToDevicePixels property on the root element in your Visual Tree (all child element will then inherit this property).

    Below the Username textbox with SnapsToDevicePixels set to false, N.B. the border is blurred:

    blurry elements: SnapsToDevicePixels = false

    Below the Username textbox with SnapsToDevicePixels set to true, N.B. the border is now crisp:

    crisp elements: SnapsToDevicePixels = true

    Seema Ramchandani has a great post explaining Pixel Snapping in more detail.

  • Showcase of Sites Powered by ASP.NET AJAX

    As Stuart eluded to in his summary of his adventures in 2006, I spent the majority of the year as the Development Lead for HMV working on their Digital Download Platform – we achieved a huge amount in 11 months (hence why I've been so quiet here); several updates to the HMV Digital Player, we created a new permanent music download store and finally a Media Centre Online Spotlight Store (I'm sure Richard Griffin will blog about this at some point as it was his "baby").

    I'm particularly proud of the permanent music download store – we set out to create a rich Web 2.0 application which delivered a simple and interesting music purchasing experience. Much kudos goes to Mike Lewis for his designs and Max Choong for his User Experience work and the dedication of the HMV developers involved. We made the decision early on that we would use Atlas (now ASP.NET AJAX) to deliver the rich interactivity and today Rory pointed out that the site is featured as part of the ASP.NET AJAX Showcase.

More Posts Next page »