markhneedham/blog huggingface dataset:
NCover - Requested value '/r' was not found
Date: 2008-08-19 21:18:44

I've been trying to integrate http://www.ncover.com/[NCover] into our build and probably making life harder for myself than it needs to be.

The title refers to the error message that I was getting when trying to run  the http://www.kiwidude.com/dotnet/doc/NCoverExplorer.NAntTasks/tasks/ncover.html[ncover nant task] on version 1.0.1 of NCover earlier today.

[source,text]
----

[ncover] Starting 'C:\Program Files\NCover\ncover-console.exe
(//r "\long\path\to\tmp392.tmp.ncoversettings" )' in 'C:\my-project\trunk\src'
[ncover] Unhandled Exception: System.ArgumentException: Requested value '/r' was not found.
[ncover]    at System.Enum.Parse(Type enumType, String value, Boolean ignoreCase)
[ncover]    at NCover.Utilities.Arguments.ParseArgument(String arg,
CommandLineArgument& key, String& value) in C:\tools\eclipse3M6\workspace\ncover\src\NCover\Utilities\Arguments.cs:line 192
----

After some inspired Googling http://markthomas.info/blog[my colleague] managed to work out that the problem was that you can't pass a settings file path which has spaces in to the ncover executable, hence the error message. It's the same problem in handling spaces that I mentioned in an link:2008/08/14/msbuild-use-outputpath-instead-of-outdir/[earlier post on msbuild].

The advice on the forum was to upgrade to one of the more recent versions where the bug has been fixed. Downloads of the free version of NCover (it becomes paid for at version 2.0) are available http://www.ncover.com/download/discontinued[here].
The transparency of Agile
Date: 2008-08-26 11:46:46

One of the key ideas behind agile software development is providing information as early as possible to allow the business to best make decisions.

There are a variety of ways that this is done including the use of http://alistair.cockburn.us/index.php/Earned-value_and_burn_charts[burn up charts], estimates of scope and velocity for example. This data is compiled to try and give an accurate idea of how long a project is likely to take so that the business can work out early on whether the value it adds is worth the expected cost.

I strongly believe in this approach, certainly favouring it over other approaches that I used before working at ThoughtWorks. However, over the last couple of months I have started to wonder whether providing the business with this information so straight up actually works against you.

I believe the way that the information is viewed is different depending on when it is provided.

For example, if you have a piece of work which is due to take 12 weeks and you work out after 3 weeks that based on the current velocity it is likely to take 14 weeks you are in a weaker position than if you keep this information to yourself and then ask for another two weeks when you get to the 12 week mark.

From the business' perspective I suppose it makes sense - if after 3 weeks you're already 2 weeks behind then who knows how far you will be behind after 14 weeks.

I am not suggesting that it's better to hold back this information but surely there has to be a better way to present it because from what I've seen the baseline figure is what's looked at and the details are ignored.

Nor am I advocating that we under estimate on purpose to get the baseline figure lower. Clearly you will end up ruining your delivery reputation if you consistently over promise and under deliver.

The driver behind the agile approach is to always add business value, and while as a developer I would prefer to try and provide something to the client, as http://markthomas.info/blog/[Mark] points out, it has become clear to me that maybe sometimes http://markthomas.info/blog/?p=55[cancellation] is the best way of doing this.
Agile - Should we track more than just development?
Date: 2008-08-26 23:57:40

I http://www.markhneedham.com/blog/2008/08/26/the-transparency-of-agile/[touched earlier] on the transparency of agile and I've been thinking about some of the ways that we track/report information in agile projects.

In all the projects I've been involved in the data being tracked almost exclusively referred to development time. One of the advantages of having continuous analysis/development/testing is that we are able to reduce the time spent on the System Integration and User Acceptance Testing phases of the project.

In a typical waterfall project most bugs would be found in these two stages of a project, and they would typically be fairly lengthy affairs.

The idea behind several of the agile practices is that the number of bugs/defects in the code base will be significantly lower than you would experience with a more traditional approach. Therefore the amount of time reserved SIT and UAT can be significantly reduced.

From what I've seen this is not always pointed out. It is almost like it is considered implicit in the fact that we are using an agile approach to software delivery and does not need to be explicitly stated.

I am now starting to believe that it does, and more than that - it should be actively pointed out as a benefit of using an agile approach.

We should be pointing out that 'Yes, it may take longer to produce the code than would be possible if we just coded it straight out with no testing but the total time from the first line of code being written until the time it's production ready will be less'. We should also point out that the benefits of our approach will only increase as more code is written and the practices practiced come into their own.

I'm not sure what the best way of doing this would be - perhaps it could be something as simple as including estimates of how long SIT/UAT will take as part of a release plan and then including these on the burn up chart.

Or is there another tool available to do this?
IntelliJ style item tracking in Visual Studio
Date: 2008-08-09 14:51:29

One of my favourite features of http://www.jetbrains.com/idea/[IntelliJ] is that it tracks the item that you currently have open on your Solution Explorer.

I thought this wasn't possible in Visual Studio and had resigned myself to trying to remember which project each file was in. Luckily for me a colleague pointed out that it is in fact possible but is just turned off by default.

Tools > Options > Projects and Solutions > Check 'Track Active Item in Solution Explorer'

image::{{<siteurl>}}/uploads/2008/08/resharper-track-item.jpg[resharper-track-item.jpg]

Job done!
scp Nant Task - 'scp' failed to start. The system cannot find the file specified
Date: 2008-08-30 16:30:41

I was trying to make use of the http://nantcontrib.sourceforge.net/[Nant Contrib] http://nantcontrib.sourceforge.net/release/latest/help/tasks/scp.html[scp task] earlier and was getting an error message which at the time seemed a bit strange (now of course having solve the problem it is obvious!)

This was the task I was running:

[source,text]
----

<scp file="someFile.txt" server="some.secure-server.com" />
----

This was the error:

[source,text]
----

'scp' failed to start.
     The system cannot find the file specified
----

I ran it in debug mode to try and see what was going on and got this stack trace:

[source,text]
----

NAnt.Core.BuildException: C:\projects\project1\default.build(18,4):
'scp' failed to start. ---> System.ComponentModel.Win32Exception: The system cannot find the file specified
   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at NAnt.Core.Tasks.ExternalProgramBase.StartProcess()
   --- End of inner exception stack trace ---
   at NAnt.Core.Tasks.ExternalProgramBase.StartProcess()
   at NAnt.Core.Tasks.ExternalProgramBase.ExecuteTask()
   at NAnt.Contrib.Tasks.ScpTask.ExecuteTask()
   at NAnt.Core.Task.Execute()
   at NAnt.Core.Target.Execute()
   at NAnt.Core.Project.Execute(String targetName, Boolean forceDependencies)
   at NAnt.Core.Project.Execute()
   at NAnt.Core.Project.Run()
----

Eventually a colleague and I realised that the scp task was *assuming* that there was an executable called 'scp' on the path.

This can be overriden by setting the 'program' attribute to whatever you want. In this case since we were running from Windows we downloaded http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html[Putty's] http://the.earth.li/~sgtatham/putty/latest/x86/pscp.exe[pscp executable] and put that on the Windows path. The code to call the scp task now looks like this:

[source,text]
----

<scp file="someFile.txt" server="some.secure-server.com" program="pscp" />
----

If you don't want to put it on the path then the following works just as well:

[source,text]
----

<scp file="someFile.txt" server="some.secure-server.com" program="c:\path\to\pscp.exe" />
----
Getting a strongly typed collection using LINQ to Xml
Date: 2008-08-30 03:03:58

I http://www.markhneedham.com/blog/2008/08/28/querying-xml-with-linq-dont-forget-the-namespace/[mentioned earlier] that I have been playing around with LINQ to Xml for parsing a Visual Studio csproj file.

While having namespace issues I decided to try and parse a simpler Xml file to try and work out what I was doing wrong.

Given this fragment of Xml:

[source,xml]
----

<Node>
  <InnerNode>mark</InnerNode>
  <InnerNode>needham</InnerNode>
</Node>
----

I wanted to get a collection(IEnumerable+++<string>+++) of InnerNode values.+++</string>+++

Unfortunately my over enthusiasm to use http://weblogs.asp.net/scottgu/archive/2007/05/15/new-orcas-language-feature-anonymous-types.aspx?CommentPosted=true[anonymous types] meant that I caused myself more problems than I needed to. This was my original (failed) effort at doing so:

[source,csharp]
----

var innerNodes = from node in projectFile.Descendants("Node").Elements()
                 select new {InnerNode = node.Value};

IList<string> innerNodesAsCollection = new List<string>();
foreach (var innerNode in innerNodes)
{
    innerNodesAsCollection.Add(innerNode.InnerNode);
}
----

A very round about way of solving the problem I'm sure you'll agree. I was sure this should be easy to do but I was making it very complicated indeed. A bit more googling revealed that I could put items straight into the collection from the LINQ query by not using anonymous types:

[source,csharp]
----

IEnumerable<string> innerNodes = from node in projectFile.Descendants("Node").Elements()
                                 select node.Value;
----

Much less code, much simpler, and a lesson in the art of not over complicating things.
If they were that rubbish...
Date: 2008-08-08 19:15:56

Jay Fields certainly seemed to make some http://www.anexperimentinscotch.com/?p=471[waves] in the blogosphere with his http://blog.jayfields.com/2008/08/elephant-in-server-room.html[recent post] about 50% of the people in business software development needing to find a new profession.

As a consultant I often go onto projects where a significant amount of difficult to understand and often untested code is in place. At times it feels like the people who have written it really don't care about the quality of their work which can be very disheartening.

There is, however, nearly always a reason that this has happened. The most frequent being that the team was under severe time pressure where getting the code into production was the be all and end all. I don't prescribe to this approach myself but if speed of delivery is the overriding priority then things which lead to quality such as Test Driven Development, OO design and Refactoring go straight out the window.

I worked on a team where we were actually explicitly told that we should stop testing our code because it would help to increase the velocity that we were achieving. The idea was that we could finish the development phase earlier and then the increased bug count would be taken care of in the UAT phase. A radically different approach than I've become used to over the last couple of years.

I only had to work like this for a few weeks and I found it very difficult. The quality of our work is one of the things that keeps developers motivated, so taking this away proved to be somewhat demoralising.

Although this approach leads to big problems when trying to add new features after the initial release, it does meet a business need otherwise these people wouldn't have a job.

At the end of the day the people with the gold make the rules so who am I to disagree.
Spaces in batch scripts
Date: 2008-08-08 20:10:49

Since reading http://www.amazon.co.uk/Pragmatic-Programmer-Andrew-Hunt/dp/020161622X/ref=sr_1_1?ie=UTF8&s=books&qid=1218153128&sr=8-1[The Pragmatic Programmer] I've become a bit of an automation junkie and writing batch scripts falls right under that category.

Unfortunately, nearly every single time I write one I forget that Windows really hates it when you have spaces in variable assignments, and I forget how to print out a usage message if the right number of parameters are not passed in.

So as much for me as for everyone else, this is how you do it:+++<table class="CodeRay" border="0">++++++<tbody>++++++<tr>++++++<td class="line_numbers" title="click to toggle" onclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }">++++++<pre>+++1+++<tt>++++++</tt>+++2+++<tt>++++++</tt>+++3+++<tt>++++++</tt>+++4+++<tt>++++++</tt>+++5+++<tt>++++++</tt>+++6+++<tt>++++++</tt>+++7+++<tt>++++++</tt>+++8+++<tt>++++++</tt>+++9+++<tt>++++++</tt>++++++<strong>+++10+++</strong>++++++<tt>++++++</tt>+++11+++<tt>++++++</tt>+++12+++<tt>++++++</tt>+++13+++<tt>++++++</tt>+++14+++<tt>++++++</tt>+++15+++<tt>++++++</tt>+++16+++<tt>++++++</tt>+++~~~
</td>
+++<td class="code">++++++<pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }">+++@ECHO off+++<tt>++++++</tt>+++IF [%1]==[] GOTO usage+++<tt>++++++</tt>+++IF [%2]==[] GOTO usage+++<tt>++++++</tt>++++++<tt>++++++</tt>+++set VAR1=%1+++<tt>++++++</tt>+++set VAR2=%2+++<tt>++++++</tt>++++++<tt>++++++</tt>+++rem important client stuff+++<tt>++++++</tt>++++++<tt>++++++</tt>+++goto end+++<tt>++++++</tt>++++++<tt>++++++</tt>+++:usage+++<tt>++++++</tt>+++echo Usage: script.bat var1 var2+++<tt>++++++</tt>++++++<tt>++++++</tt>+++:end+++<tt>++++++</tt>+++echo Script finished~~~
</td>
</tr>
</tbody></table>+++</pre>++++++</td>++++++</pre>++++++</td>++++++</tr>++++++</tbody>++++++</table>+++
TeamCity's strange default build location
Date: 2008-08-08 19:52:50

We've been using http://www.jetbrains.com/teamcity/[TeamCity] on my current project and it's proven to be fairly impressive in general.

We're running quite a few different builds which have dependencies on each other and it's been pretty much one click on the web admin tool to get that set up.

One thing that had me really confused is the default location it chooses to build from. The problem is that it seems to change arbitrarily, with the folder name it builds in being calculated from a VSC hash (not sure quite how that's worked out but there we go).

I had (naively) assumed that the default build location would always stay the same and was therefore referencing this location from our build script. Turns out it can change whenever it feels like it!

Our 15:38 build was built to c:/TeamCity/Agent/c734523aedrte but our 15:40 build was built to c:/TeamCity/Agent/d6420ghi2.

Cue much confusion as I repeatedly looked at the first folder trying desperately to work out why nothing was being checked out. Eventually, more by fluke than skill, I figured it out and our build is now being built to c:/WorkingDirectory every time.

Lesson learnt: Take control and set your default directory, don't let TeamCity do it for you!
Keyboard shortcut for running tests with Resharper
Date: 2008-08-08 19:23:13

Having moved back into the world of C#/.NET development after a few months in the Java world I have had the joy of getting to use http://www.jetbrains.com/resharper/[Resharper] again.

One annoyance that myself and my team have been having over the past few weeks is running unit tests. We always end up going to the Solution Explorer, right click the project and then click 'Run Unit Tests'. There is another way...

From Visual Studio:

* Click on Tools > Options > Keyboard
* Select the 'Show commands containing' box and type in 'resharper.resharper_unittest'.
* Select 'Resharper.Resharper_UnitTest_ContextRun'
* Assign this to a keyboard shortcut (I usually use Shift-F11 as that's the same as IntelliJ!) and running unit tests need never be a pain again.

image::{{<siteurl>}}/uploads/2008/08/resharper-screenshot.jpg[resharper-screenshot.jpg]
First thoughts on using var in C# 3.0 with Resharper
Date: 2008-08-15 08:03:09

One of the first things I noticed when coming into the world of C# 3.0 was the use of the key word 'var' all over our code base.

I had read about it previously and was under the impression that its main use would be when writing code around LINQ or when creating anonymous types.

On getting http://www.jetbrains.com/resharper/[Resharper] to tidy up my code I noticed that just about every variable type declaration had been removed and replaced with var. Very confused I asked one of my colleague's what was going on. It turns out that this is intended and is now http://resharper.blogspot.com/2007/08/resharper-vs-c-30-implicitly-typed.html[Resharper's default]. I quickly found the option and turned it off.

Subsequent discussions have led me to believe that perhaps it is not such a bad thing. When I first saw the use of var I felt that the readability of the code was severely impacted, and I still think that this is the case if method bodies have a lot of code in.

Therefore using var in your code seems to encourage you to keep the methods short so that people can actually understand what's going on. This leads to much easier to understand and maintain code.

Of course the discipline to make this happen is still needed but in the way that the lack of static typing in Ruby encouraged the writing of unit tests (I am led to believe), hopefully the use of var will encourage short compact methods.

The http://resharper.blogspot.com/[Resharper blog] has a http://resharper.blogspot.com/2008/03/varification-using-implicitly-typed.html[post] explaining why they have decided to make var so prevalent in the code refactoring that Resharper does. Included amongst these is better naming of local variables.

Having reading http://www.xpteam.com/[Jeff Bay's] essay in http://www.pragprog.com/titles/twa/thoughtworks-anthology[The ThoughtWorks Anthology] about clean OO design I have become quite fanatical about the naming of variables. I like them to be as descriptive as possible so that I can immediately tell what an object is doing without having to look at the details. Shortcuts such as naming an instance of an Account object as 'acct' are pointless in my opinion and just serve to confuse people.

Any language feature that helps encourage the writing of clear variable names is therefore a very good thing.

http://www.25hoursaday.com/weblog/2008/05/21/C30ImplicitTypeDeclarationsToVarOrNotToVar.aspx[Dare Obasanjo] seems to dislike this new feature while http://flimflan.com/blog/ToVar.aspx[Joshua Flanaghan] is more of a fan so clearly the jury is still out.
Dependency Tasks
Date: 2008-08-12 23:48:40

I am a big fan of Pat Kua's http://www.thekua.com/atwork/2007/07/19/onboarding-strategy-tiny-tasks[tiny tasks] and to see my desk would be to believe that there had been an invasion of yellow stickies on the planet.

Pat explains the idea on his website but to summarise; the idea is that given a story, you break it down into the individual tasks that need to be done in order for it to be complete, write each tasks on a sticky and then when that task is finished throw the sticky away.

This has really well for me because I am inclined to lose focus/get distracted and having a list of tasks that I need to do helps keep me on track.

This week it has come to me that perhaps the metaphor needs to be extended slightly. There have been a couple of occasions when I have been working on something and I complete all the tasks I needed to, but then I break something else which was reliant on something that I changed.

The work I'm doing is in the build area so the idea of having a suite of tests to protect me from making that mistake is not there.

My immediate thought is that along with writing the tiny tasks I should also write some dependency tasks which will help me to recognise what things are reliant on the story I am doing, and therefore allow me to either make the necessary changes in these areas or just not break them!

In a way I suppose this is just an extension of the idea of tiny tasks but for me it requires a bigger picture look at how what I'm doing effects the rest of the world and therefore it makes sense for me to view the two things separately right now.

I'm going to give this idea a try and report back on how it's worked out. Hopefully it will stop me breaking things quite so much. As always any ideas are welcome.
Getting the current working directory from DOS or Batch file
Date: 2008-08-12 22:37:27

In the world of batch files I've been trying for ages to work out how to get the current/present working directory to make the batch script I'm working on a bit more flexible.

In Unix it's easy, just call 'pwd' and you have it. I wasn't expecting something that simple in Windows but it is! A call to 'cd' is all that's needed. If you need to set it in a batch script the following line does the trick:+++<table class="CodeRay" border="0">++++++<tbody>++++++<tr>++++++<td class="line_numbers" title="click to toggle" onclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }">++++++<pre>++++++<tt>++++++</tt>+++~~~
</td>
+++<td class="code">++++++<pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }">+++set WORKING_DIRECTORY=%cd%~~~
</td>
</tr>
</tbody></table>
I was surprised that something so simple (I do now feel like an idiot) wasn't easier to find on Google. I ended up going via Experts Exchange (how they end up with such high search results when you have to pay to see the information is beyond me) and several other +++<a href="http://www.codeguru.com/forum/archive/index.php/t-96124.html">+++verbose ways+++</a>+++ of solving the problem before finally coming across +++<a href="http://blogs.msdn.com/oldnewthing/archive/2005/01/28/362565.aspx">+++this article+++</a>+++ which explained it.+++</pre>++++++</td>++++++</pre>++++++</td>++++++</tr>++++++</tbody>++++++</table>+++