Tuesday, March 30, 2010

Number of TFS checkins

I was trying to work out how many times I have checked code into TFS for each project that I've worked on in a given date range. I still haven't managed to work out how to break it down by project but did get the total count.

  • Ran Team Foundation Sidekicks.
  • On History tab select my User name in the drop down.
  • Clicked the "Save list to file" button.

Problem with this CSV list is that I have line breaks in many of the comments so it's not a true CSV file.

  • Using Notepad++
  • Ctrl+F for search and change the Search Mode to Regular Expression.
  • Enter "^\d+," without quotes in the Find what field.
  • Click the "Find all in Current Document" or the "Count" button to get the number of lines with that pattern.

That will be the number of items that you checked in.

The regex ^\d+, can be roughly interpreted as find all lines starting with (^) a string of one or more numbers (\d+) and ending with a comma (,).

This is probably one of the most unwieldy and ugliest solutions to a problem I have recently come up with. Also, I haven't managed to work out how to breakdown check-ins by project. Any ideas?

Wednesday, March 24, 2010

Mercurial Commit Push Pull Update

I'm just starting to wrap my head around Mercurial and feel that this is the best diagram that I've seen that explains the push/pull commit/update model.
 To get or retrieve changes from your working directory to the "server" directory is always a two step process.
To "check-in" you will commit your changes to your local repository and then push them to the server.
To "get latest" you will pull from the server and then update to your working directory.


Source: http://www.ivy.fr/mercurial/ref/v1.0/Mercurial-QuickStart-v1.0-300dpi.png

Wednesday, March 17, 2010

Make Better Software: The Training Series

The company that I work for recently bought my team the Make Better Software: The Training Series done by Joel Spolsky at Fog Creek Software. This is my report on this course.

I've listened to all the Stack Overflow podcasts with Jeff Atwood and Joel Spolsky and so I now "get" that Joel is only pretending to be arrogant and his manner is intended to provoke debate. He does it well.

The six one-hour videos in the course are very well done. They were easy to watch and packed with good content and extremely well edited. Every now and then you felt like it was teetering on the edge of a sales pitch for either the product that they sell or for candidates to apply for a job at their company but considering that it was all about working at Fog Creek and creating Fog Bugz it would have been very difficult to not do this now and then.

The manual (Student Guide) that comes with the videos was not as well prepared as the videos. It is essentially a collection of Joel's blog post over the last 10 years divided into six sections. I found at least two blog posts that were repeated verbatim in two different sections and there were paragraphs that were repeated and some of the blogs seemed to have text missing off the end. This was slightly unprofessional and a bit irksome. I'm not sure if anybody proofread or edited the compilation of these.

In the table of contents he has a "chapter" titled "Incentive Pay Considered Harful", italics and bold are mine. I've heard Joel criticize candidates for submitting resumes with spelling mistakes in them with comments like "there's no excuse for that, don't they know how to use a spell checker."

Despite my criticism of the spelling and lack-of-proof-reading I consider the content to be good. It duplicates what is said in the video and in some parts goes a bit deeper and has the names and references that you might miss when watching the video of that section.

The course starts off with The Joel Test. We score fairly high on the Joel test with a 10. We don't do point 3 (daily builds) but instead we build on every check-in which is more rigorous than he is proposing.

After the Joel Test the course is divided into 6 modules:

  1. Recruiting
  2. Team Members
  3. Environment
  4. Schedules
  5. Lifecycle
  6. Design of Software

From a management point of view all modules are relevant but more so modules 1 to 4. I felt that Program Managers were the main focus in the Team Members section but all members were covered and some myths dispelled.

Fog Creek appear to have the best environment for almost anybody to work in let alone developers. It's interesting that the offices given to developers are not only to increase productivity but are a huge sales tool in recruiting talent.

My point of view is that of a developer. As such I found the second half of the course more interesting. Joel did an excellent job of convincing me about the value in specifications and I no longer feel that they are a waste of time but rather something that needs to be continuously worked on while a project is alive.

Would I recommend this course? Absolutely.


Tuesday, March 2, 2010

LINQ secondary sort using extension method syntax

You have a list of objects that you want to sort using LINQ. You want to sort by a primary and secondary key from the fields (properties or members) of the object. How do you do this?

The answer is to do two sorts. The first by the secondary key and the second by the primary key. Here's a little test console app that you can run to verify.

class Widget
    public int First { get; set; }
    public int Second { get; set; }
class Program
    static void Main(string[] args)
        List<Widget> widgets = new List<Widget>();
        widgets.Add(new Widget { First = 1, Second = 6 });
        widgets.Add(new Widget { First = 2, Second = 6 });
        widgets.Add(new Widget { First = 3, Second = 5 });
        widgets.Add(new Widget { First = 4, Second = 5 });
        widgets.Add(new Widget { First = 5, Second = 4 });
        widgets.Add(new Widget { First = 6, Second = 4 });

        var firstSort = widgets.
          OrderByDescending(a => a.First).
            OrderBy(a => a.Second);
        foreach (Widget widget in firstSort)
            Console.WriteLine("First {0} Second {1}",
                widget.First, widget.Second);


The results of this run are:

First 6 Second 4
First 5 Second 4
First 4 Second 5
First 3 Second 5
First 2 Second 6
First 1 Second 6
Hit return to continue...

So we initially reverse sort by the First property, this will be the secondary sort. We then sort by the Second property, this will be the primary sort.