A New Project (part 2)

David left a comment to my previous post rightly pointing out that I’d omitted MbUnit from the list of tools. Considering that omission I also realised that I’d missed a few other tools. For completeness sake I’ve decided to include them in this follow-up post.

Tortoise and Subversion 3Star

I wasn’t new to Tortoise or Subversion but my previous encounters with them had left something of a bitter taste. In particular the lack of Visual Studio integration, the difficulty involved in moving code around (renaming) and the fact that I was always discovering files from the solution that I’d forgotten to manually add to the repository.

For the last 8 months I’ve been using Team Foundation Server’s source control and its interesting to compare the two. It seems to me that each one’s major strength is also their weaknesses. For example, when working on a small team in which “everyone owns the code” it can sometimes be very useful to know what is currently being worked on – i.e. checked out by another user. TFS supports this by being aware of all check-outs which means you often know which files you need to be careful about when merging, or you may decide not to modify the file until the other developer has checked it in. Of course the downside of this is that TFS’s offline capabilities become a lot more complicated (bad). Subversion is the opposite – you’ve got no idea what’s being worked on – but it means working offline requires no smarts at all.

The big discriminator for me at the moment between TFS and SVN is the quality of the merging tools. TFS warns you about any conflicts, giving you the option to perform manual or automatic merging on each file. I haven’t figured out how to do this in SVN – it just does the merge for you and prompts when it can’t resolve a conflict. The problem is that this auto-merge is just way to optimistic about its own capabilities. Or to put it another way – it sucks! It gets it wrong frequently – i.e. once every couple of days. If you’re lucky you notice straight away (for example the app doesn’t compile). If you’re unlucky its rolled back some code, or duplicated a line which you’ll find out about down the track when odd bugs start (re-)appearing. [If anyone has any pointers on this I’m all ears – because in my experience its scarily bad – I’m starting to resort to manually checking every file prior to commit.]

Visual SVN 4Star

We went for a couple of weeks without having any Visual Studio integration. Things worked OK – but it did seem kinda redundant having an Explorer window open to perform source control operations. Especially as Explorer isn’t to flash at refreshing itself, so icons are often lagging unless a forced refresh is done.

Visual SVN has been doing a great job and was cheap to boot. Renames are so much nicer!

MbUnit 4Star

We’re using MbUnit as our testing framework. To date I’ve just treated it almost as I would have NUnit or the built in MS namespaces. However, just the addition of the Row attribute makes MbUnit worth having. This is a tool (along with Rhino Mocks) that I really need to dig around a bit more with as I’m sure there are plenty of hidden gems I’m not making good use of.

TestDriven.NET 

Testing menus everywhere. Job done.

Wireless Internet

After much “mulling-over” I finally decided to get a Wireless Internet account. I looked into each of the obvious Vendors – 3, Optus and Vodafone. Of those only Optus had a pre-paid service – the other two offered only 24 month plans that required a credit check and lots of stupid questions. On closer inspection though Optus’s 2Gb for $30 pre-paid plan began to look less inviting. In addition the pre-paid blocks expire after 30 days and the fine print states that usage is measured in 10Mb increments. So connecting and downloading a 1Kb file will accrue 10Mb of usage! On a 2Gb plan that’s only 200 individual connections?!

As it turned out the best plan for me was the least obvious. Telstra. Yep – that’s right – Telstra. Apparently since 24-Aug-2008 their ludicrously expensive Wireless broadband plans have dropped to become well err… just very expensive. A 1Gb plan now only costs $60 per month on a 36 month plan. But here’s the deal-making points for me:

  • No credit checks and stupid questions – even if you’re not an existing customer (which I am).
  • Modem included in price.
  • Best coverage.
  • Ability to change up/down quota with no penalties.
  • Half price for first 12 months – making it on par with best 3 and Optus plans.
  • At the end of 12 months simply drop the plan and rejoin for another 12 months at half price. Plan cancellation fee of $240 – which I’m willing to pay above and beyond Optus and 3 for:
       12 month plan instead of 24 month,
       better coverage,
       better joining experience.

Trust me I was amazed as anyone – I now have a Bigpond account. This morning I would have expected the end of time to have occurred prior to that event happening.

I live in an area where the exchange is declared by Telstra as “full” and hence ADSL 2 is not available. I found a nifty web site – www.speedtest.net – and ran two tests. [Seriously if you haven’t already seen speedtest go check it out – its a very slick looking web-app.]

My 1500/256 ADSL account with Internode.

My new Next G account with Telstra.

Unfortunately I’m unlikely to ever use that speed. The 1Gb plan is just enough for e-mail, messenger and occasional web browsing whilst I’m on the move.

A New Project

About five weeks ago I changed jobs – well I guess more accurately I took on another job but that’s a long story.

One of the key highlights of the new challenge was the technology stack:

  • Visual Studio 2008 SP1
  • WPF
  • NHibernate
  • SQL 2008
  • Sync Services for ADO.NET
  • Rhino Mocks
  • Resharper
  • CruiseControl
  • NCover
  • Castle

A lot of these tools I hadn’t had a chance to use in a commercial environment before. We’re at the point now where we’re handing over the first release of the software to system testing – in a couple of weeks it will be rolled out to a selection of  end users. I thought this would be a good opportunity for me to jot down my current feelings towards these tools – something to reflect on at a later date.

Visual Studio 2008 SP1 4Star

Finally I get to use C# 3.0 at work – yay! Lambdas, LINQ, var, object initializers – aahh such sweet stuff. Unfortunately, though SP1 bought a lot of goodness and fixed a few issues with XAML editing its also got one or two nasty glitches. Every now and then Visual Studio just “disappears” when opening a XAML file. If you reload the solution – poof – it closes down again. The trick is to make sure the Toolbox is un-pinned when opening the solution again. Sometimes even that doesn’t do the trick though and you have to delete the solutions SUO file before re-opening.

WPF 5Star

Awesome (yeah I’m biased ). Still finding it hard to do certain things that should really be easy – but the pain is so much less than when I first started last year. Of course there are a bunch of improvements I’d like to see – particularly around the visual designer. Makes me long for one of those jobs on the Cider team that Karl posted about now he’s been absorbed by Microsoft. “Build a Resource Manager”… “How about a Data Binding Explorer”…

SQL 2008 4Star

Haven’t really got into this as much as I’d like – there’s no real killer feature – but there are plenty of smaller features that really make it worthwhile. Change Tracking, Intellisense (when it decides to work), Resource Manager, Tools for Express editions, decent date types better matching the .NET types etc.

Sync Services for ADO.NET 5Star

Love this stuff – has a few quirks but generally provides you with lots of depth. The wizard gets you started but you can drill into it as deep as you want – down to handwriting all the SQL yourself.

Rhino Mocks 3Star

Mocking frameworks were new to me. I understand the principles – but I’d never bothered with one before – preferring instead to create and maintain my own concrete mock objects where possible. I’m finding Rhino Mocks to be quite a struggle – at times its bliss – at others its just plain frustrating. Need to keep working on this one.

NCover

Well if nothing else its convinced me that 100% code coverage means relatively little. In fact I think chasing code coverage percentages is generally detrimental to the quality of the overall tests. Not really fair to rate this one – it does what its supposed to do very well – I’m just not convinced that what its supposed to do is worth doing.

Resharper 2Star

Some great features in this package. I love the highlighting of redundant code blocks (casts, variables, pointless condition tests etc). Also has some nice navigation hot keys. However, its slows my (brand new 4Gb RAM) machine to a crawl, the Intellisense and formatting is just plain intrusive (so much so I switched most of it off) and it crashes frequently. Often when it crashes it throws up a stupid “would you like to submit this crash” dialog that just takes me that much closer to uninstalling the package – particularly when I’ve told it countless times not to show me that dialog!

To sum this one up its got some great features – but they come at a significant cost. This is only still installed on my machine because I believe its the type of product you really need to commit some effort to before you can break through the pain barrier.

CruiseControl 4Star

I have recently been using TFS which I’m a big fan of but I’ve used CruiseControl before and it certainly does a great job.

NHibernate 1Star

Probably the reason the project wasn’t finished a week earlier. I wasn’t really expecting too much from NHibernate – after all its just an ORM right? We’ve got some clever people working on our team [though admittedly I don’t think any would consider themselves an NHibernate expert] but every minor thing has been a struggle. Some examples:

  • Using our own collections for one to many relationships – why is this so hard!?
  • Creating a simple two level inheritance hierarchy – how can this not be trivial?
  • Having to have nullable parent foreign keys in some scenarios because NHibernate insists on performing an insert prior to updating the parent foreign key. Why can’t it determine the dependency order and do the inserts in the right sequence?
  • Eager loading generates idiotic queries. Reference data e.g. code lookups are fetched using individual SELECTs rather than by joining on the main table – WTF? So what could be done in one SELECT is instead done in several thousand (if you have several thousand rows).

As things stand I would never recommend this tool. If you’ve got a simple database your time is better spent writing your own data access layer rather than struggling with NHibernate’s peculiarities. If you’ve got a complex database then spend the time to investigate other alternatives. I cringe to think that NHibernate could really be the ORM of cho
ice for an enterprise app.

Castle 4Star

We’ve been using Castle Windsor as our IoC. Previously I’d used Unity and, in the simple method that we’re using an IoC, there really isn’t any difference between them. Windsor does the job very nicely and I’m really enjoying working on an application that is so loosely coupled.

For performing validation in the business layer we’re also using Castle’s Validation components. These are really lightweight and provide some very simple property level validation through the use of attributes. Simple but nicely encapsulated. We’ve expanded this to work with our own entity level validation and then hooked that into the WPF Validation pipeline when those business objects are attached to a UI.

Castle documentation (what there is of it) sucks.

__________________________

Well – like I said – this is really my initial reaction to these tools. As the project progresses I’m sure some of these will change (for better or worse). Feel free to flame me if you think I’ve made some poor judgement calls.

BindingGroup Secrets Revealed

When Visual Studio 2008 SP1 Beta was released it was hinted that new data binding functionality would be available for WPF applications using a new BindingGroup class.

Well with the release of SP1 RTM the BindingGroup surfaces – no longer such a well guarded secret. On the other hand it hasn’t exactly been promoted as a key new feature? I’ve yet to find a mention of it aside from the original reference by Brad Abrams.

I’ve only taken a quick glance thus far – but what I’ve seem looks promising. I was hoping for a method to overcome the clumsy “find a bound control” hack, but couldn’t find it. However, it does provide a BindingExpressions collection which provides an easy mechanism to identify all bindings for a given FrameworkElement (including all its children). Well – for those that care – here’s the MSDN documentation for BindingGroup.

Also of interest, but swamped by the SP1 RTM headlines a CTP for the forthcoming WPF DataGrid!

UPDATE: Vincent Sibal explains BindingGroup in full.

Dr Horrible, favourite Sci-Fi Show and Authors

For fans of Joss Whedon – creator of Firefly (a brilliant, though short-lived Sci-Fi series) comes “Dr Horrible”. This is a three act musical comedy that he made during the writer’s strike (ie. no studio involvement). Definitely worth watching! [Joss also did Buffy the Vampire Slayer (but I forgive him) hence he has a cult following that melted the servers they originally posted this to. An additional 2.2 million downloads in its first week on iTunes too.]

I also get surprised by the number of people that haven’t read Iain M Banks book – my favourite sci-fi author (though he does contemporary fiction too). There’s a great intro on the Culture civilization that spans many of his books here.

I guess while I’m at it, if you’re doing fantasy fiction is there really anyone better that Guy Gavriel Kay?

Why DataTemplates Rock!

In the recent Screencasts I did on creating an Occasionally Connected app my user interface consisted of a ListBox and a few buttons. The ListBox was used to display the list of Holidays read from a locally cached database. The application has now evolved where that early prototype has become the initial “selection screen” for the HolidayPlanner application.

Here is the screen using a ResourceDictionary (Resources\Simple.xaml) with the bare minimum required to be usable:

HolidaySelectionSimple

And here’s the XAML behind it:

<Window x:Class="ADOSyncSampleSP1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dm="clr-namespace:HolidayPlanner.DataModel"
xmlns:cm="clr-namespace:Spencen.PresentationLayer.Commands"
Title="Occasionally Connected Application Demo" Height="581.783" Width="551.777" Language="en-AU">
    <DockPanel Name="dockPanel1" VerticalAlignment="Stretch" LastChildFill="True">
<TabControl DockPanel.Dock="Top">
<TabItem Header="Plan">
<ToolBarTray>
<ToolBar Header="Select Holiday">
<Button cm:CommandBinder.Command="{Binding NewCommand}"/>
<Button cm:CommandBinder.Command="{Binding PropertiesCommand}"/>
</ToolBar>
<ToolBar Header="Configuration">
<Button cm:CommandBinder.Command="{Binding SecurityCommand}"/>
<Button cm:CommandBinder.Command="{Binding NetworkSettingsCommand}"/>
<Button cm:CommandBinder.Command="{Binding SettingsCommand}"/>
</ToolBar>
</ToolBarTray>
</TabItem>
<TabItem Header="Experience">
<ToolBarTray>
<ToolBar Header="Select Holiday" >
<Button cm:CommandBinder.Command="{Binding OpenCommand}"/>
</ToolBar>
</ToolBarTray>
</TabItem>
<TabItem Header="Review">
<ToolBarTray>
<ToolBar>
<Button cm:CommandBinder.Command="{Binding SynchronizeCommand}"/>
</ToolBar>
</ToolBarTray>
</TabItem>
</TabControl>
<ListBox Name="listBox1" ItemsSource="{Binding Holidays}" HorizontalAlignment="Stretch" 
ScrollViewer.CanContentScroll="True" ScrollViewer.VerticalScrollBarVisibility
="Visible"> <ListBox.InputBindings> <KeyBinding Command="ApplicationCommands.Open" Key="Enter"/> </ListBox.InputBindings> <ListBox.GroupStyle> <GroupStyle HeaderTemplate="{StaticResource HolidayGroupHeader}"/> </ListBox.GroupStyle> <ListBox.ItemsPanel> <ItemsPanelTemplate> <VirtualizingStackPanel Orientation="Vertical" VirtualizingStackPanel.VirtualizationMode="Recycling"/> </ItemsPanelTemplate> </ListBox.ItemsPanel> </ListBox> </DockPanel> </Window>

What I love about WPF’s templating and styling system is that with a single line change to the App.xaml I can swap out the vanilla DataTemplates with something more appealing. So changing this:

<Application x:Class="ADOSyncSampleSP1.App"

   
xmlns
=http://schemas.microsoft.com/winfx/2006/xaml/presentation

   
xmlns:x
=http://schemas.microsoft.com/winfx/2006/xaml

    StartupUri
="Views/MainWindow.xaml">

    <
Application.Resources
>

        <
ResourceDictionary
>

            <
ResourceDictionary.MergedDictionaries
>

                <
ResourceDictionary Source
="Resources/Simple.xaml"/>

           
</ResourceDictionary.MergedDictionaries> 
        </
ResourceDictionary
>

    </
Application.Resources
>

</
Application>

To this:

<Application x:Class="ADOSyncSampleSP1.App"

   
xmlns
=http://schemas.microsoft.com/winfx/2006/xaml/presentation

   
xmlns:x
=http://schemas.microsoft.com/winfx/2006/xaml

    StartupUri
="Views/MainWindow.xaml">

    <
Application.Resources
>

        <
ResourceDictionary
>

            <
ResourceDictionary.MergedDictionaries
>

                   <
ResourceDictionary Source
="Resources/Standard.xaml"/>

           
</ResourceDictionary.MergedDictionaries> 
        </
ResourceDictionary
>

    </
Application.Resources
>

</
Application>

Changes the front screen as shown below without changing any of the behaviours (other than adding UI enhancements such as hot tracking etc.)

HolidaySelectionStandard

At this point I must admit I was feeling kinda proud of myself. But then two things happened to change this.

Firstly I watched DNR TV episode 115 where Billy Hollis shows how WPF allows developers to bring new user interface paradigms into their applications. Now my own user interface begins to look a little bit like “lipstick on a pig”. I can’t help looking through the veil and seeing that same old toolbar and listbox from the Windows 95 era.

Secondly, a few weeks ago I attended the first day of CodeCampSA. During this a guy by the name of Alan Boldock gave a very entertaining talk on his experiences creating appealing user interfaces using WPF. During this presentation he showed off some quick samples of the work his team had been doing. I was sitting in the audience putting together some final tweaks on my new Resources\Standard.xaml resource dictionary. Again, it was somewhat demoralizing, I couldn’t help but think that I just hadn’t embraced the potential that WPF could offer.

There was nothing for it – I had to come to grips with my “inner-designer”. I tried coaxing my alter-ego out by wearing the closest thing I could find to a turtleneck sweater. Bravely I cracked open Expression Design and painstakingly put together something that I could export out as the new DataTemplate for the Holiday class. So I add another line to the App.xaml to include the new DataTemplate, and switched the ListBox to be Horizontal rather than Vertical.

            <ResourceDictionary.MergedDictionaries>

                <ResourceDictionary
Source
="Resources/Standard.xaml"/>

                     <ResourceDictionary Source="Resources/PhotoAlbum.xaml"/>

           
</ResourceDictionary.MergedDictionaries> 

Here’s the end result:

HolidaySelectionAlbum

Well, granted its not particularly artistic, nor innovative – but I still got a warm, fuzzy feeling seeing my new selection screen. [Or maybe that was just from the itchy old sweater? ]