User Stories and Use Cases

Writing Effective Use Cases by Alistair Cockburn

I was wondering what the difference between User Stories and Use Cases was and more importantly whether they were mutually exclusive or could be combined - my experience of Scrum so far seems to lean firmly toward the former.

However, I was distracted from my brief search when I came across Why I still use use cases written by Alistair Cockburn the author of Writing Effective Use Cases. In this article he’s made some interesting observations based on experience visiting companies and even goes as far as stating “naïve use of user stories and backlog items is causing very real, very expensive damage to companies”.

I’m blogging this because I’m interested in hearing other viewpoints and experiences from those who have worked with user stories as I’m mindful that this particular article could invoke hugely disparate opinions.

Can you Bing it?

Another day, another search engine. Microsoft have just delivered www.bing.com (beta) in an effort to get another verb into the dictionary! Of course there has to be some new features and in their press statement they’re talking about Decision Engines, Best Match, Deep Links, Quick Preview, Instant Answers and my particular favourite Sentiment Extraction!! Maybe it’s just re-branding, but you never know… it might produce better results that google?

image

Using LinqPad for running code snippets

I’ve been meaning to blog about this for ages. I’ve been using an utterly fantastic tool called LinqPad for a while now and find it invaluable. I initially downloaded the free version to run and learn Linq, however I’ve started to use it a lot more for running normal C# code.

The benefit of LinqPad over Visual Studio is I don’t need to create a project or save anything to the disk (although this feature does seem to be coming in Visual Studio 2010.) Instead, I can just type an arbitrary C# statement, hit F5 and see the results. That may not sound so great but the other feature I find invaluable is the way it displays results. Here are a couple of examples:

In this example I’m using the extension method Dump() which LinqPad has made available to nicely display the contents of an array. Notice the title that can be supplied and also the complete lack of a Main():

image

Not that impressed? Ok how about an example using List<> containing an anonymous type:

image

And here’s another example where I’m using the ‘C# Program’ option rather then ‘C# Statement(s)’ – selected from the language drop down in the toolbar. This provides me with a Main() function by default. However, there’s a slighty nasty hack to allow me to add my own classes – I have to close the Program class generate behind-the-scenes by LinqPad and remember not to close the last class I define. I can live with that. This screenshot is also showing the standard intellisense features that you all know and love although you do have to fork out cash for this (currently $19) :

image

What I haven’t described are all the cool features related to Linq which includes being able to click a button and see the SQL that Linq to SQL has generated and executed against the database. And if you want to keep a library of snippets then you can save your ‘queries’ in a file where they’ll be displayed in the interface (bottom left) and can be managed in a standard folder hierarchy.

I love this tool… kudos to Joseph Albahari – he’s done a fantastic job.

Add Comment Filed Under [ .Net Dev Tools ]
T-SQL Delete Performance Problem

I’ve been working on an archiving solution for one of our products but was suffering from a disastrous performance problem with a relatively simple SQL statement. Here’s the problematic SQL :

delete from c
from #CodeToArchive cta
join Code c on c.oid = cta.oid

#CodeToArchive is a temporary table containing one column of primary keys to be deleted from the table Code. With the temporary table only containing about 100 rows this statement still took over 5 minutes to complete!

Running an execution plan highlighted that the delete from Code wasn’t the problem :

image

…but lower down the problem became apparent. The Code primary key is a foreign key in a number of other tables and one in particular, the Reward table, was causing the problem :

image

Whilst all other foreign keys were all using Nested Loops and Index Seeks, Reward ended up a Merge Join with an Index Scan despite the fact there was an index on the foreign key. That fat arrow is highlighting a transfer of 24 million rows totalling about 600Mb!! The estimated and actual row counts both matched which suggested the statistics were all up-to-date.

Lots of head-scratching and an epiphany later and things were sorted but we had to fool the query optimiser! The problem was the Code foreign key on Reward was full of nulls (and before you ask, this particular piece of application functionality wasn’t yet being used in this installation so we couldn’t just remove the foreign key) and this was fooling the query optimiser into thinking it had to search the entire index.

The solution was to give the optimiser a hand into realising there’s not quite so much data that it needs to look at, so a join to reward with a where clause did the trick :

delete from c
from #CodeToArchive cta
join Code c on c.oid = cta.oid
join Reward r on r.code = c.oid
where r.code is not null
Tracking open windows in Visual Studio (or not!)

I always found it a bit annoying when I’d close a code window in Visual Studio but then VS would automatically expand my nicely arranged Solution Explorer just so it could highlight the next active code window. To my relief there’s an option buried in Tools –> Options that I can turn off :

image

GUI Automation

There are plenty of frameworks for automating GUI’s but often have a hefty price tag. Well there’s one for free called WASP and it’s for PowerShell. I’ve not used it yet myself but with a really simple set of cmdlet’s such as Select-Window, Select-Control, Send-Click and Send-Keys it looks like a really easy way to build up simple scripts. I could imagine this being fairly useful for developing some simple integration test scripts.

Shrinking a partition in Windows Vista (and possibly other versions?)

Hands up who knew there was an option in Vista’s Computer Management Console to shrink a partition? I didn’t and I discovered it whilst pondering the options for installing a Beta of Windows 7. Mind you, even though I’ve got a complete imaged backup of my laptop with Acronis True Image (a great product in my opinon) I haven’t built up the courage to use this option just yet. The help suggests it relocates files to create the new unallocated space but I’m always a bit nervous mucking about like this – anyone had any experience?

image

Selecting a result set from a stored procedure in SQL Server

Selecting data from a stored procedure in SQL Server is already a documented feature and here’s an example:

insert into #systables exec sp_executesql N'select * from Northwind.sys.tables'

…problem is this example doesn’t run without first creating the temp table and therefore knowing all the column definitions. When I’m running quick queries this isn’t exactly convenient. I’ve seen blogs posts using a linked server but there’s another way :

select * into #systables 
from openrowset(
   'sqlncli', 
   'server=.;trusted_connection=Yes', 
   'sp_executesql N''select * from Northwind.sys.tables'''
)
I wouldn’t necessarily use this as a day-to-day process on a production environment but for administration or scripting installations I think it fits the bill.
Running SQL Server 2005 Reporting Services in IIS7 on Vista

I’ve been trying to navigate to my reporting services on the url http://localhost/reportserver/reportserver2005.asmx but keep getting an internal server error 0x8007007b in the AboMapperCustom-96221 handler :

image

I took a look at the AboMapperCustom-96221 handler (IIS manager –> ReportServer virtual directory –> Feature View –> Handler Mappings) and found that the executable path has a double-backslash :

image

I’ve taken one out and saved changes and allowed the ISAPI extension :

image

An IISReset later and everything seems to be working.

Oh… but don’t forget to run the ReportServer virtual directory in the Classic .Net AppPool. You can do this manually in the IIS manager or use the ‘Reporting Services Configuration Manager’ that comes with SQL Server.

SQL Server Differential Backups and Primary Key choice!

I’ve just set up a weekly full database backup and daily differential daily backups thinking that this would not only speed the daily process up but also reduce the amount of data that’s flying around the servers since our backups are topping 85gigs. However, I was disappointed to notice that the first differential backup containing only a days worth of transactions is already 27gigs even though the quantity of transactions is a lot less.

A quick google and a ‘eureka’ moment seems to have highlighted the problem. A differential backup identifies the data that has changed since the last backup but backs up the entire Extent that the data exists in. (An Extent is 64kb and contains 8 Pages where each Page is 8kb.) That would have been fine except the primary keys we are using are generated as unique guids – which means any data added to a table during the day is randomly, and probably evenly, distributed across the Extents. That’s the ‘eureka’ moment… the differential backup is identifying sparsely updated Extents and so artificially inflating the backup.

Along with the other performance problems we’ve had in the past this is lending more weight to using something along the lines of newsequentialid() function but there’s more details blogged by Jimmy Nilsson which details some alternatives.