Tests 3 to 8

  • I take a look at the code and wonder if I can tidy it up at all (refactor) … and I can’t see anything[1].

  • So I add in the next test: 3 = “II”, it fails, I change the code so it passes, but I still can’t see anything to refactor.

  • I repeat this process for tests 4, 5, 6, 7, 8, adding each test – one at a time – making it work, trying to refactor.

  • I start to think that this could be a long and drawn out process. I can’t see anything that I can easily refactor.

Public Function i2r(i As Integer) As String

If i = 1 Then

i2r = "I"

ElseIf i = 2 Then

i2r = "II"

ElseIf i = 3 Then

i2r = "III"

ElseIf i = 4 Then

i2r = "IV"

ElseIf i = 5 Then

i2r = "V"

ElseIf i = 6 Then

i2r = "VI"

ElseIf i = 7 Then

i2r = "VII"

ElseIf i = 8 Then

i2r = "VIII"

End If

End Function

[1] One of my very experienced programmer friends told me that I could have refactored the code at this stage by sorting out the repeating “I”s, for example. But, to be honest, I’m not a programmer any more and I didn’t feel I could do so comfortably.