Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Preface

foo,bar,baz are instantly recognizable signifiers of example or pseudo code. Their popularity seems to be a strong indication that the programming community accepts them as a good way to indicate the author is showcasing a non-specific implementation of code. As this q+a reveals they are classified as metasyntactic variables.

While the history of these words seems to be rooted in over 50+ years of usage I can't find any resources studying their effectiveness.

Question

Rather than take it a face value that their ubiquity is evidence for the effectiveness I'm wondering if there is evidence about the impact on linguistic comprehension.

To clarify, I know that foo is understood as signifying pseudo-code, but I'm referring to comprehension of what the pseudo-code means.

Why

I have re-read the FAQ many times and before I get accused of being chatty I'm not trying to elicit a discussion, I'm not looking for personal anecdotes, I'm asking a question that is relevant to the programming community at large though it's on the edge of our concerns. I realize that there may be not anything published in this area but in case there is it'd be helpful to know in either case.

share|improve this question
1  
You don't need a study for this, just some common sense. foo, bar and baz are intended for syntactic demonstrations, where context doesn't matter. If you need context, as in result = repository.getCustomer(id), foo = bar(baz) is clearly going to be inadequate. –  Robert Harvey Jan 23 '13 at 0:45
    
Good question! The origins are widely discussed in this question: programmers.stackexchange.com/questions/69788/… but none of the answers explore their effectiveness for use in example code. –  Jay Elston Jan 23 '13 at 1:08
    
Then my sense is perhaps uncommon because I've never appreciated the second level of abstraction required. var dog = new Dog or var myVar = new MyClass are way more transparent in my book. –  Mark Fox Jan 24 '13 at 4:14

1 Answer 1

Foobar is effective at keeping the reader focused on the point you are trying to illustrate. It prevents their mind from going off on tangents.

//demonstration of the "dot" syntax
new Foo().bar().baz();

vs

//demonstration of the "dot" syntax
new FireTruck().honkHorn().measureDecibals();

The firetruck example fills your mind with fire trucks. You may even want to argue with the instructor that measureDecibals() is not be a behavior of a horn honking. You may have a good point, but it is a tangent and not relevant to the dot syntax which is being illustrated.

FYI. Little known fact. Foobar is the phonic spelling of the FUBAR acronym. F***ed up beyond all recognition.

share|improve this answer
    
Little known according to...? –  Amy Blankenship Jan 23 '13 at 3:44
    
I've always thought 'foo' and 'bar' FUBARed example code. Hence my curiosity. –  Mark Fox Jan 24 '13 at 4:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.