开发者

FizzBuzz comment that confused me - are hard coded conditions wrong?

开发者 https://www.devze.com 2023-01-21 17:23 出处:网络
I discovered the \"FizzBuzz\" question today at coding horror.Great article.However, something in one of the user-comments confused me --here\'s the quote:

I discovered the "FizzBuzz" question today at coding horror. Great article. However, something in one of the user-comments confused me -- here's the quote:

Geez guys - EVERY ONE of you who gave example code - EVERY ONE - hard coded the FIZZ and BUZZ conditions...

It sounds to me like this poster is ridiculing people for "hard-coding" conditions, ie :

if(i % 3 == 0)
...

What is point the poster is trying to make? Is there another way to开发者_如何学运维 specify conditions in a program?

Thanks for taking the time!

Dan

the FIZZ and BUZZ conditions...


The point of Fizz Buzz is to quickly weed out non-programmers, not find the best programmer. Any reasonable function that meets the specification is acceptable for this test.

If you don't hardcode, great, you extra-pass. But, that doesn't get you out of the hard questions that are following. I usually increase the difficulty with each question, but I don't want to waste time if the candidate totally can't answer simple questions.


There's nothing wrong with hardcoding some conditions.

In the context of an interview, when I know that I'm coding FizzBuzz.java and not Enterprise Fizz Buzz with a database and 1000+ simultaneous users requiring five-nines uptime, it's ideal to hardcode these conditions.

Entry-level programmers, the ones you ask FizzBuzz at least, are to follow specifications and make solutions as simple and elegant as possible. If you're an agile software house, including such features goes against YAGNI and should be discouraged. If the interviewer doesn't ask the ability to use other factors besides three and five, then it wasn't in the spec and therefore isn't needed.


It's meant as a joke.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号