Team dojo 12

Today we continued where the last dojo ended. Since last time we've created a small backlog with user stories using this tool. And we implemented one user story; As a robot developer I want to be able to turn my robot. Apart from a long interesting design discussion we also covered another interesting topic; if you want to test an algorithm, do you want to duplicate the algorithm in the test code or just use hard coded values. Let me give two examples:

  1: Assert.AreEqual(Robot.TURN_SIZE * 2, robot.Heading); 
 2: Assert.AreEqual(180, robot.Heading);

On the first line we use a constant to calculate the expected value and in the second case we use the value we're actually expecting. The good thing with the first alternative is that if the constants change the test will still pass. But they danger is if we cut-n-paste the "algorithm" both the test code and the production code may have the same error. If you write the algorithm twice (once in the test and once in production) it is probably OK but you don't know. The second variant will break if we change the constant changes but on the other hand the test is very clear in what the intention of the developer was. And if the constant changes, maybe it is good that some tests fail if you change the constant since it gives the developer a good chance revisit the intention of each test.