--
You received this message because you are subscribed to the Google Groups "belfastjs" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/belfastjs/-/vIXVxRQhWb0J.
To post to this group, send an email to belf...@googlegroups.com.
To unsubscribe from this group, send email to belfastjs+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/belfastjs?hl=en-GB.
On Thursday, 10 May 2012 at 11:09, davidlowry wrote:
--
To unsubscribe from this group, send email to belfastjs+unsubscribe@googlegroups.com.
To unsubscribe from this group, send email to belfastjs+unsubscribe@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "belfastjs" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/belfastjs/-/yr6MHATMSI8J.
To post to this group, send an email to belf...@googlegroups.com.
To unsubscribe from this group, send email to belfastjs+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/belfastjs?hl=en-GB.
Stephen, not really, your test cases can assert on a single reply to
the algorithm... and that is where your solution would be totally
changed.
You are basing your solution in the fact that you are counting from 1
to 100 (which right now is a requirement for you, and it can change),
but you are not isolating the algorithm that computes FizzBuzz, but
embedding it into that initial requirement. The solution is very
coupled (I know it's only fizzbuzz!).
If you had something like FizzBuzz.say(1), then you can assert that
the result is '1'. FizzBuzz.say(3) would expect 'Fizz'.
Your general solution would be something like a for loop to
MAX_FIZZBUZZ calling FizzBuzz.say(i) inside. Now all your pieces are
modularised and can evolve and change separately. You could even reuse
your fizzbuzz module in... well, not in many other problems I'd say :D
Is this overkill for a problem like Fizz Buzz? definitely, but are you
trying to solve fizzbuzz or are you deliberately practicing your
coding skills? that, of course, is up to you.
cheers,
José
[...]