Showing posts from June, 2021

A look into the process of refactoring and TDD

Today i figured i'd show, and talk about the evolution of a feature using TDD and refactoring (but mainly show). To start, i already had a tested system for adding nodes, which simply set _currentStrength to whatever node was added, but did not yet add the notion concept that these nodes were arranged in a grid, My goal was to add this feature. Starting off with a few quickfire tests to get the basic concept into place.   Blue arrows: order of steps Squares: Added/changed code. +: new test case Notice how by the end of this process i've written 5 separate test cases, and yet the thing still cannot store more than 1 item at a time ( _currentStrength is not a collection of any kind), This is a sign to "future me" that this feature still needs to be finished. This actually makes life a lot easier, since you have very obvious signs of what still needs to be done embedded into the code. C# also allows you to basically "summarize" the testcases above nicely usin