From: Rob Biedenharn Date: 2007-06-02T03:56:16+09:00 Subject: Re: FizzBuzz (#126) On Jun 1, 2007, at 2:17 PM, Mike Mondragon wrote: > On 6/1/07, Chris Shea wrote: >> On Jun 1, 11:53 am, "Mike Mondragon" wrote: >> > On 6/1/07, Daniel Martin wrote: >> > I worked with a lead in a java shop that liked to ask this >> question: >> > >> > "Write a function that reverses the *words* in a string" (in java) >> > >> > Firstly, it would reveal if the candidate listens to the problem >> and >> > then goes about logically solving what was communicated to them >> (i.e. >> > its not reversing the string character by character). If they get >> > crafty with the problem then kudos to them, but if they get stuck >> > she'll say that its ok to use java util classes to help solve the >> > problem. Secondly if stuck since they claim to be java programmers >> > then they should know about the StringTokenizer combined with Stack >> > classes that makes this problem trivial to solve. >> > >> > At first I thought this question was too simplistic (much like >> > FizzBuzz), but it really does fletch out the Heros from the Zeros. >> >> Isn't your test ambiguous? Do you want "Hello World" to become "World >> Hello" or "olleH dlroW"? Or is that part of the test? > > Ah yes, thanks for jogging my memory, "Write a function that reverses > the words of a string" I'd think that would be another opportunity to see how the person works. Do they notice the potential ambiguity of the requirement? If not, how do they react when the other interpretation (from the one they assumed) is pointed out? Of course, giving one of the specifications: assert_equal "World Hello", reverse_words("Hello World") assert_equal "olleH dlroW", reverse_words("Hello World") would clear the matter up (when asked). (And it's been a couple years since I've looked at JUnit so just imagine the equivalent Java syntax ;-) -Rob Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com