<https://medium.com/@wakingrufus/writing-testable-...
# feed
m
@wakingrufus Nice write up. Thanks for sharing. I'm all for DI, but here are my thoughts on your example.
fun fizzBuzz
does two things; generating a list of fizzbuzz-numbers and present the list (print). I would separate the two (single responsibility principle) and either have
fun fizzBuzz
return the list of fizzbuzz-numbers or perhaps even better, yield the values, and the do presentation somewhere else. Thus making DI superfluous in this case.
w
I agree, but the code here was just to illustrate the technique. If I was actually trying to do fizzbuzz, I would not do it this way