Hacker News new | ask | show | jobs
by Myk267 4452 days ago
The value in FizzBuzz is the iteration process.

What's the first step? Well, you probably make a stream of numbers. And then a set of if blocks to test and return strings. Why not keep going?

What happens if you want more fizz buzz strings? Does the giant if-or statement seem a little unwieldy? Okay, pull the rules out and see if that's better. Is it easier to test now that it's a function and not a little stateful object? Do you want your fizzbuzz function to concatenate the strings or use explicit replacement? Can you make a switch for that? And so on.

That stuff only scratches the surface. I'm sure there's some brain burning fizz-buzz interviewers out there. It really puts you on the spot to deal with a stateful program.

One thing that seems really weird to me is this: given the first set of rules, why does almost everyone write the program that is the least extensible? Is it the way the question is phrased or scar tissue from imperative programming?

1 comments

YAGNI.