You ain't gonna need it
Today I worked on the tests for my new App. The App is developed using Test Driven Development (TDD). I needed a method which converts decimal numbers into fraction numbers. So with an input of 1.5 the method should give the output 1 ½.
First I tried to make that method as general as possible. I though about, how to convert something like 0.3. But one important think one has to remember in TDD:
Only implement code you need to pass the test.
This is better known as You ain't gonna need it. (YAGNI) It turned out that I only needed fractional numbers with precision of ¼. So the only numbers I had to cover have been 0, ¼, ½, ¾, 1, ...
This could be done with a simple if-else-if statement.
This was very simple. The principle "You ain't gonna need it" saved me a lot of time.