Friday, July 06, 2007

Tip:#1 Testing Events in C#

If you have a class that causes a .Net event to fire. When writing a test for the event, you can add a handler to the event that sets a flag that you then assert on in your code. Using normal delegates means the variable would need to be a class member and get initialized in Setup. Use of anonymous delegates cleans this up nicely.

[Test]
public void TriggerEvent_CausesEventThatFiresToFire()
{
Customer customer = new Customer("Ben");
string changedPropertyName = null;

customer.PropertyChanged += delegate(object sender, PropertyChangedEventArgs args)
{changedPropertyName = args.PropertyName;};

customer.Name = "Kate";

Assert.AreEqual("Kate",changedPropertyName);
}

Thursday, June 28, 2007

Design for unit testing

Object oriented languages allow lots of ways to solve the same problem. As you get better at design you see some designs as good [loose coupling, high cohesion]. You can view your design skills as a set of filters you use to choose which design to pick.

Doing TDD leads you to learning some new filters. If a design is not testable it is not a valid design. I want to write an article on this.. but for now check this out: http://www.codeproject.com/useritems/DesignPatternsForUnitTest.asp

Monday, May 21, 2007

SVN vs ClearCase

At a current client we just swapped over from using ClearCase and ClearQuest to using SVN with clear check in comments within our team and updating the ClearCase repository daily.

The change in productivity is striking. One team member mentioned today that he felt he was saving around 2 hours a day. If that's accurate then on a team of 8 people it's equivalent to freeing up 2 people every day.

It's not just the time spent waiting for version control, but those pauses people make to 'quickly' grab a drink or check their email so the pair are not there when the tool does finish. Not only that, everyone is having more fun too. No one likes waiting for hour glasses. Everyone likes feeling more productive.

Are any steps in your processes disrupting the flow of your work? Can a change of tools help?

The key is to work out the features of the current process that are actually require and which are just nice to have.

Tuesday, April 24, 2007

Ping Pong Programming

Ping Pong Programming

Aim: To get your pair to do the hard work.

Setup: The game begins with a failing test. Players take turns...

Turns: You have 3 options

1
a/ Make the failing test pass
b/ Do any refactoring you can see
c/ Write or Uncomment a new failing test

2
a/ Comment out the failing test
b/ Write a simpler failing test

3
a/ Comment out the failing test
b/ Refactor to simplify the code
c/ Write or Uncomment a failing test

Hints: If your turn is longer than 3 minutes try option 2 or 3

Notes: Give this a go and notice how frequently you change drivers. Great when you have a pair that hog the keyboard.

Sunday, April 22, 2007

Freelancing on Rails

If you are freelancing as a software developer and especially if you are focused on rails, you should check out Craig Ambrose's podcast series.

I have had the pleasure to work with Craig at both Torus Games and Open Windows, and always find him insightful, pragmatic, and a pleasure to work with.

Check it out at http://www.craigambrose.com/podcasts

GitHub Projects