DEV Community


Discussion on: Solve this simple problem with TDD

jon_fm profile image
Jon Sullivan

Well forgive me for being a rather wordy fellow but the tail end of my solution does outline the very specific red/green tests you could write to TDD the problem... I just give a lot of foundational theory basis for why I chose those tests ;)

You can TDD anything given the right mindset :D

@michelemauro I didn't read streams or infinite lists as being part of the parameters of the problem but the same solution could be slightly adjusted (really just in ResponsibilityB to handle infinite sequences and/or streams pretty readily.

Anyway, all around good conversation guys - cheers πŸ‘πŸ»

Thread Thread
delbetu profile image
M Bellucci Author

Ok, as soon as I have some free time I'll try to follow your tests and tell you back what was my experience.
thank you!

Thread Thread
delbetu profile image
M Bellucci Author

Reading again all of your answer so you are describing an algorithm which possibly solves the problem and you identify two sub problem that can be tested individually,

This is a valid technique for solving a problem but is totally the opposite of tdd

Because in tdd you don’t know the solution in advance, as you resolve every micro test with the minimum amount of code to satisfy the test you discover the algorithm.
So you don’t know the algorithm in advance.