Dan Dan The Kanban Man

Just finished a new page for my Information Radiator. This one shows the progress of user stories through the process. We do scrum and this is a kanban-style board so I’m mixing things up a little bit but I think it’s fine.

Most Salesmen understand waterfall. They promise a feature to a customer within set timescales to get cash. That’s what salesmen will always do. Of course, life gets in the way and something pushes their new feature back. In waterworld they get a nice new Gantt chart which shows what’s been added into the project, they understand why it’s there and accept it. The Kanban board is an agile answer to the same question: “Why are you not working on the trans-galactic hyperdrive I promised? Oh, it’s because you’re fixing a radiation leak in the cosmic flange-o-tron. I agree that’s important and I guess you should fix it before you do my feature”.

StoryKanban2

The data is pulled from TFS. I don’t differentiate between development and QA on the board because I think it sends the wrong message – we’re just one big team, after all!

StoryKanban3

Hopefully this board will help those outside of the development and product teams get a better understanding of what we’re working on now, what we’ve finished, what we’re doing next and why. Knowing the answers to those questions gives people a warm and fuzzy glow inside and helps ease inter-departmental tensions.

Insulation

I’ve decided to add some more “creature comforts” to The Duke. I am sick of the noise and the condensation that runs down my neck when I start off on cold mornings. I didn’t much like the ice that formed on the inside of the walls when we went camping back in December either!

After much research I found some 7mm thick closed-cell “van insulation” foam on eBay. It cost me £70 for 8m and I used 7m of it lining the roof and walls. A couple of cans of “trimfix” glue were included in the price. I almost managed to do the whole job with just one can of glue but had to open the second for the last roof section over the front seats!

20130421_180253

It looks like the international space station in there now! Emma enjoyed looking around once I was finished – though she still refers to The Duke as “Daddy’s Tractor”.

20130421_180343

It was all pretty easy except the final section over the front seats. The roof tapers and the chunk of foam needed to be aligned on all sides. I had to peel and re-stick several times before I got it right.

Went out for a test drive and I can confirm that it’s still very noisy in there. Not sure if the newly insulated roof helped much as the overdrive whine is still deafening at motorway speeds. I still have the door seals to replace and maybe I’ll stick the last metre of insulation under the bonnet to see if that makes a difference!

It does seem to help with the heat a little – it was sunny this weekend and the uninsulated skin of the roof was hot enough to (slowly) cook an egg. Insulated sections are much less hot to the touch.

South West Coast – Lands End to (almost) The Lizard

Several years ago we finished the northern section of the South West Coast Path. This week a smaller group of us went back to take on the next section – Lands End to The Lizard.

We managed 16 “strenuous” miles on day one, 18 “moderate” miles on day two and then cut day three short to 8 more moderate miles. We didn’t make the Lizard, but we had fun trying! The landscape was beautiful but the weather was cruel to say the least. Snack breaks on day three were bitterly cold with a constant freezing wind blowing head-on as we walked. Can’t complain too much though as the rest of the UK was hit by unseasonal snowstorms.

We witnessed a real life air-sea rescue on day two. An RAF Sea King turned up to winch a fisherman from the freezing sea after he’d been swept off the rocks. We were convinced they were pulling out a corpse but next day the local radio confirmed he had miraculously survived the 10-foot swells, jagged rocks and freezing water. Watching the rescue unfold from the coast path left us in awe but also a little shaken. Coastal erosion was in full swing and we often found ourselves on detours around huge new cracks in the ground or navigating slippery wet rocks above certain-death falls. Maybe these things are best done in the summer!

That said, it was fantastic to notch up another 42 miles of stunning coastline. Hopefully next year will see us back in Cornwall for the next section of walking and more warm pub parlours, good beer and fresh fish suppers.

Using a BufferBlock to Read and process in Parallel

Wrote an app this week – top secret of course – to load data from a database and process the contents. The reading from the database is the slow part and the processing takes slightly less time. I decided it might help if I could read a batch of results into memory and process it while loading the next batch.

Batching was dead easy, I found an excellent extension method on the internet that batches up an enumerable and yields you a sequence of arrays. The code looks like this, in case you can’t be bothered to click the link:

public static IEnumerable<T[]> Batch<T>(this IEnumerable<T> sequence, int batchSize)
{
    var batch = new List<T>(batchSize);

    foreach (var item in sequence)
    {
        batch.Add(item);

        if (batch.Count >= batchSize)
        {
            yield return batch.ToArray();
            batch.Clear();
        }   
    }  

    if (batch.Count > 0)
    {
        yield return batch.ToArray();
        batch.Clear();
    }  
}

That works really well, but it doesn’t give me the parallel read and process I’m looking for. After a large amount of research, some help from an esteemed colleague and quite a bit of inappropriate language, I ended up with the following. It uses the BufferBlock class which is a new thing from Microsoft’s new Dataflow Pipeline libraries (which provide all sorts of very useful stuff which I may well write an article on at a later date). The BufferBlock marshals data over thread boundaries in a very clean and simple way.

public static IEnumerable<T[]> BatchAsync<T>(this IEnumerable<T> sequence, int batchSize)
{
    BufferBlock<T[]> buffer = new BufferBlock<T[]>();

    var reader = new Thread(() =>
        {
            foreach (var batch in sequence.Batch(batchSize))
            {
                buffer.Post(batch);
            }
            buffer.Post(null);
            buffer.Complete();
        }) { Name = "Batch Reader Async" };
    reader.Start();

    T[] blocktoProcess;
    while ((blocktoProcess = buffer.Receive()) != null)
    {
        yield return blocktoProcess;
    }
}

The database read is done on a new thread and data is pulled back to the calling thread in batches. This makes for nice clean code on the consumer side!

MOT 2013

Passed first time! Advisories on rusty exhaust, slight steering play and worm shock absorber bushes.

Celebrated by driving through a flood in Tidmarsh at high speed. Good times!

Bulk Inserts to SQL Server Azure

This has been driving me mad all day, so I’ll document it here if only so I don’t forget!

SQL Server Azure doesn’t support the “traditional” batch insert stuff and you can’t just send an SQL file with 50,000+ “insert into…” statements either as the query processor will run out of space.

What you can do is run a tool called BCP.  This tool is specially designed for loading large datasets into the cloud and is perfect for all your dimension table needs.  The tool takes a tab delimited file as input as well as a huge list of command line parameters.

C:\>bcp [myDatabase].[dbo].[TableName] in C:\Users\Dan.Taylor\Dropbox\Stuff\DansDataFile.txt -c -U dansUsername
@dansAzureServerName -P <password> -S tcp:dansAzureServerName.database.windows.net -e c:\errors.txt

Piping the errored records to a text file is very helpful!

BCP

The first column in my table is an auto-generated ID, so I make sure that every line in my file starts with a tab. This basically nulls the first column, letting the database generate an ID as normal.

Also, BCP can not parse dates, times or datetimes from strings. I haven’t found a nice way around this yet – in the end I changed the data type of the column because I don’t really care about the date in my dataset very much anyway! Others have said they created a temporary table and then select/inserted the data over to the real table with a date conversion.

EZSnap Motor Mounts

I really liked my old motor mounts for the Quadrotor. I made them on the lathe out of “Engineering Nylon” which costs very little, is easy to machine and can be found on eBay (search for “nylon round bar”). The motor snuggly fits into a 9mm hole and is fixed with two 3mm hex head set screws from either side. Another 3mm set screw goes through the bottom and bolts the mount onto the frame. To stop the torque from the motor spinning the mount I milled a 10mm wide slot into the bottom which fits over the aluminium frame.

I liked them because they are light, look nice and form an integral part of the frame (so no extra cable ties and fixings, just one bolt to do everything). The big problem made itself very apparent when I had a crash on the airbase; the motor hit the ground first and because there was no “give” in the motor mount I bent the arm and broke the motor (detaching one of the magnets).

20130219_074255

This would never have happened in the old days – when the factory motor mount was attached to the frame with cable ties. It might have been ugly, but the cable ties would snap long before any other damage could be done.

So, how could I improve my nice looking “purpose built” motor mounts to add a weak point? The answer is in the next picture:

20130227_225105

Basically it’s exactly the same design, but with an added cable tie! This time I made the mounts in two parts: a base part which bolts securely to the frame and a motor part which sits on the base and is held down by a cable tie. There’s a little knob on the motor part which sit in the 5.5mm hole in the base part (at the bottom of which the hex-head of the set screw goes). This keeps the two parts locked together as long as the cable tie is in place.

In a crash the cable tie will snap and the motor part will detach – hopefully protecting the motor from damage and protecting the frame in the event of a “motor-first” crash.

20130227_225453

Have I tested them yet? Well, no. I’m not going to crash on purpose!