Tuesday, September 28, 2010

Unit- and integration tests makes our code harder to maintain

There seem to be a common misunderstanding and hype by many developers and project managers that unit- and integration tests make our code easier to maintain. In my experience this is not the case. It's just as hard, if not harder, to write good and maintainable tests as there are to write good code in general. Due to this I often see developers commenting out their tests when changing or refactoring code, as the smallest change causes too many tests to break and it just makes it unmaintainable. Does this mean that we should not write tests? No, but in the same way as we work on sharpening our skills on writing good and maintainable code, we also need to sharpen our test writing skills.

Sunday, September 26, 2010

How to restore an Acer easyStore H340 Windows Home Server

This is how you restore an Acer easyStore H340 Windows Home Server:

1. Insert the Server Recovery Disc into any PC connected to the network where the Home Server is connected.
2. Turn off the server.
3. Take a paper clip and press it into the pinhole at the back right on the server while you turn it on. Keep the paper clipped pressed until you see a red light flashing.
4. Wait until the network icon on the server is flashing blue.
5. Follow the wizard from 1) to either reinstall Windows Home Server and preserve the data or to do a factory reset.

Wednesday, September 8, 2010

C#: How to let a method accept a variable number of arguments

The params keyword in C# lets you specify a method parameter that takes a variable number of arguments:


public int AddNumbers(params int[] numbers)
{
 var sum = 0;

 foreach (var number in numbers)
  sum = sum + number;

 return sum;
}

Usage:


var sum1 = AddNumbers(1, 2);
var sum2 = AddNumbers(1,2, 3);
var sum3 = AddNumbers(1,2, 3, 4);
var sum4 = AddNumbers(1,2, 3, 4, 5);