Rob Smyth

Tuesday 24 June 2008

Specific Data Types Avoid Primitives Confusion

An interesting confusion occured today at work one the interpretation of a method parameter named something like 'widgetPercentage'. One developer took 5% as being 0.05 and the original author expected 5% to 5.0. My first thought is that we are missing a 'Percentage' type to remove this ambiguity. But, this would require a constuctor that took a percentage as a sting like 'Percentage("5%")'. Seems fine, but both an example of my loathing of such strings and the lack of use of strong types. I do 'feel' that a strong type could have avoided the problem here.

NCoverCop And Warm Fuzzy Green

Right now I'm coding at home on an open source project and it is surprising just how much I miss a build box running NCoverCop . Each time I want to add a feature I feel the old tug between TDD and hacking. It seem that this 'tug' is dimished at work as NCoverCop makes sure that no new code goes in without tests, at home I still have the temptress devil on my shoulder.

'Interesting' how I find working with NCoverCop a relief rather than a burden. NCoverCop in fact provides the "warm and fuzzy" of a TDD green. It just feels good with and like driving without a seatbelt without.

Friday 20 June 2008

Golley & Violet's New Kennel

When we moved into our home we inherited an old kennel for the dog's in their dog run. The dogs have loved it, but it finally fell apart. So I've built them a new one.

In the past our dogs have had individual kennels and never used them. The differences were:
  • Lots of straw
  • Large - 1.6 meters square
  • Large front opening (three walls)
  • Postioned so they could see the house and garden from it
The dog run is surrounded by large trees and we have had one or two large branches fall into it each year. One did hit the old kennel. So, to give a strong kennel to protect the dogs, I build a large A frame kennel. I used 7mm thick sheets to save time. It seems to be successfull but if I was doing it again I would give the sheets more support, they are warping a bit.

The new one is bigger and the dogs love it. :-)

Tuesday 17 June 2008

Mocking Generic Methods with NMock2

Mocking generic methods is a bit of a problem using my preferred mocking framework NMock2 but Nigel has found a way. Check out his blog or download his NUnitExtensions project. Great time savers.

The NUnitExtensions project I have in my NoeticTools google project is inspired by Nigel's. I intend to delete mine and use Nigel's one.

Another good one Nigel.

Sunday 1 June 2008

Programmatic Pane Nesting Using DockPanel Suite

I've blogged before on DockPanel Suite and I'm using this framework in my VicFireReader project. In the last week I've had a need to programmatically split the right pane vertically so that I have a top right pane and a bottom right pane as shown in the picture. The code fragment below shows how it was done. 'contentPanel3' is docked to the bottom right.

public MDIParent()

DockPanel dockPanel = new DockPanel();
dockPanel.Dock = DockStyle.Fill;
dockPanel.BackColor = Color.Beige;

DockContent content1 = GetDockContentForm("Content 1", DockState.Document, Color.SteelBlue);

DockContent content2 = GetDockContentForm("Content 2", DockState.DockRight, Color.DarkSeaGreen);

DockContent content3 = GetDockContentForm("Content 3", DockState.Float, Color.PaleGoldenrod);

private DockContent GetDockContentForm(string name, DockState showHint, Color backColour)
DockContent content1 = new DockContent();
content1.Name = name;
content1.TabText = name;
content1.Text = name;
content1.ShowHint = showHint;
content1.BackColor = backColour;
return content1;