Requirements and Specs Are Always Ambiguous

UPDATE: As an aside, it would probably be more accurate to say the FizzBuzz question is a Requirement. So where you read the term Spec, you can replace it with Requirement. Either way, the same thing applies. The only thing not ambiguous is the code. As they say, the code is the spec.

One last point, then I’m done with this topic of FizzBuzz and spec writing. In a recent post, I mentioned tongue firmly in cheek that the FizzBuzz “spec” has certain flaws. Now I admit I’m taking this out of context a bit to make a point. FizzBuzz is an simple interview question, not a spec, possbily intended to elicit this type of analysis from the candidate. Even so, I think there’s a good lesson to learn here.

My point was that all specs are merely rough approximations of the actual requirement. Specs are ambiguous, but software is not. Software doesn’t generally deal well with ambiguity. Change a random bit in memory and all hell breaks loose.

However, some of that was lost due to the extremely nitpicky point I made about the spec. So here’s another, still nitpicky, but a bit less so.

Every so called “correct” program written in the comments of Jeff’s blog had the following output.

1
2
Fizz
4
Buzz
Fizz
7
Fizz
Buzz
11
Fizz
13
14
FizzBuzz

But, doesn’t the following output meet the letter of the spec (difference in bold)?

1
2
Fizz
4
5Buzz
Fizz
7
8
Fizz
10Buzz
11
Fizz
13
14
FizzBuzz

My point being, the spec is explicit about replacing numbers divisible by three with “Fizz”, but it doesn’t say to replace numbers divisible by five.

Yes, I agree. Developers should not act like total logicians and nitpick every detail. Human language is inexact, and we have to deal with that fact of life. Unfortunately, sofware doesn’t have the same resiliency towards ambiguity. If this output was meant to be fed into another software system, this ambiguity would cause bad data, software crashes, who knows what calamity!

You might say I’m splitting hairs here. Of course I am because the compiler is going to split hairs. The Web Service I’m trying to call is going to split hairs. The HTML browser is going to try and not split hairs, but is going to ultimately fail. Software is all about splitting hairs.

Instead, we need to move beyond the spec and ask questions before writing code, during writing code, and after writing code. Do not be afraid to talk to the customer or customer representative. That’s all I was trying to say.

Thanks to Rob Conery who was trying to make this point in my comments, but it was lost on everybody. ;)

What others have said

Requesting Gravatar... Haacked Mar 08, 2007 6:00 PM
# re: Specs Are Always Ambiguous
Or is this valid output?

12Fizz45BuzzFizz78Fizz10Buzz11Fizz1314FizzBuzz
Requesting Gravatar... Rob Conery Mar 08, 2007 6:18 PM
# re: Specs Are Always Ambiguous
I like Reg's article on this whole thing. I'm not sure how many read it (and the point he was trying to make) or just read Jeff's rant on it. But Reg's point is NOT if the solution is offered, it's HOW the solution is offered. Check out his ideas on the solutions (he's specifically talking about one he created):


...this is a toy problem. Unless you load the question down with requirements that their answer resemble production code, why should you have any expectation that the candidate only knows one way to write software?

...The no-hopers won’t get it no matter how simple the question, and the good people won’t waste a lot of time with JavaDoc and xUnit.

Sort of hard-core but it reflects the need to ask, and ask again, what's expected. And then repeat it back :).

I think your post is right on here Phil; unfortunately that doesn't matter when you're face down on the bar wondering why you can't pass interview tests :). Probably the worst thing is another dev creating the question:


I think I'll make them do this with real numbers, not integers...
Requesting Gravatar... Aaron Robinson Mar 08, 2007 6:20 PM
# re: Requirements and Specs Are Always Ambiguous
For the divisible by 3 and 5 rule, why are you replacing the 15? The spec for that point doesn't say "instead of" like it does for three? Where's the consistency? ;)
Requesting Gravatar... Haacked Mar 08, 2007 6:33 PM
# re: Requirements and Specs Are Always Ambiguous
Heh heh. Well it says "replace the number if its divisible by 3". 15 is divisible by 3. Hence...
Requesting Gravatar... Darren Kopp Mar 09, 2007 8:44 AM
# re: Requirements and Specs Are Always Ambiguous
please. just let this topic die.
Requesting Gravatar... Rob Conery Mar 09, 2007 10:10 AM
# re: Requirements and Specs Are Always Ambiguous
Darren I agree (RE FizzBuzz) but Phil's point is so critically important for many reasons. Most of which is financial. Not knowing how to ask questions and dive deep on requirements takes more time and costs more money. While I'd like to make sure I never see FizzBuzz again, the issues it's raising are core to what we do (and why I think it's so popular).
Requesting Gravatar... Haacked Mar 09, 2007 1:59 PM
# re: Requirements and Specs Are Always Ambiguous
@Darren - consider it dead. Although as Rob points out this particular topic I wrote about is a different topic.

It's about understanding clients.
Requesting Gravatar... Ryan Smith Mar 09, 2007 2:24 PM
# re: Requirements and Specs Are Always Ambiguous
I like you point about asking questions before you write code, while your writing code, and after you write the code.

The fact is, your always going to have to make some assumptions about how the software should work without being told. Sometimes these assumptions will be incorrect, but that's why you come back after the code is written and review the final functionality.

I know some amazing software developers that are a million times better at writing code then I'll probably ever be, but their ability to understand the underlying problem and solve it without having a clearly defined spec is not that great.

I think one of the best traits of a great software developer is the ability to understand the problem space and deliver a solution without the need to have every line of code defined in a spec. As Atwood put it a while ago:

"In software, we rarely have meaningful requirements. Even if we do, the only measure of success that matters is whether our solution solves the customer's shifting idea of what their problem is."
Requesting Gravatar... Owen Mar 11, 2007 6:53 PM
# re: Requirements and Specs Are Always Ambiguous
Well if you use FIT you can make it so that the customers TESTS are the specification, a much nicer way IMHO
Requesting Gravatar... you've been HAACKED Aug 21, 2007 9:24 AM
# I Knew How To Validate An Email Address Until I Read The RFC
I Knew How To Validate An Email Address Until I Read The RFC
Requesting Gravatar... Chris Oct 18, 2007 11:48 PM
# re: Requirements and Specs Are Always Ambiguous
Hi,

I agree with the point of your post, i.e. communicate to ensure that the objectives and the implementations are as aligned as possible, but i could not resist to point something you say i feel deeply untrue.

So you said :
>>Human language is inexact, and we have to deal with that fact of life.
>>Unfortunately, sofware doesn't have the same resiliency towards ambiguity.

I would like to point that as far as you are communicating, either speaking to somebody or writing code in a computer language that will be compiled and deployed on a particular plateform, you HAVE to make asumptions about the context. I belive any language, human or not, have ambiguities that only the context can solve.

Even with proper input, you software can run good on one plateform, and break on another, just because the assumptions of the developer are not valid anymore on the other plateform. I believe ambiguity is part of any process of communication, either human or mechanical. But both humans and machines are fault tolerant, up to a certain limit.

Imagine a taxi driver who is told to drive faster. Does this mean that he has to never slow down to the risk of an accident ? He needs to understand the request, just as any software component, in order to fulfill his mission correctly. And to understand the request means to have great knowledge of the context.

From this point of view, softwares, or better, computers, are no different than people : they need to deal at multiple levels with ambiguities and errors, as those are inherant to any form of communication, because of what communication is by itself.

But maybe i misunderstood your point :o)

Cheers,

Christian
Requesting Gravatar... Haacked Oct 19, 2007 1:30 AM
# re: Requirements and Specs Are Always Ambiguous
Interesting point, but I still stand by my statement. Sure software can run in different contexts and platforms, but the software itself is rarely "managing" ambiguity.

Rather, the software was unambiguously written to be cross-platform and the the platform adheres to certain standards such that the code can wrong. But the software can't handle ambiguity well. For example, suppose the the platform deviates from the cross-platform standards. Most likely the software will fail at some point. Or imagine randomly flipping a few bits in the software. How well would it run?

Hewoevr, a haumn rdaneig the Eslngih luanagge has no pbloerm cpmoreendhing tihs snneetce. Now that is dealing with ambiguity. Catch my drift?
Requesting Gravatar... kale yikma Aug 29, 2010 5:27 PM
# re: Requirements and Specs Are Always Ambiguous
Thanks. This helped a lot.

What do you have to say?

(will show your gravatar)
Please add 8 and 4 and type the answer here: