Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does foo mean? [closed]

Tags:

java

I've seen a lot of people using "foo" as method names or class names in java on Stackoverflow and other things. What's foo? Is it just a generic name for any method, class, etc. or does it actually mean anything? And why foo? Is it only for java or do people use it for other languages too?

like image 878
Dale22599 Avatar asked Nov 26 '13 04:11

Dale22599


People also ask

What is foo stand for?

Foo (pronounced FOO) is a term used by programmers as a placeholder for a value that can change, depending on conditions or on information passed to the program. Foo and other words like it are formally known as metasyntactic variables.

Why is it called foo?

According to an Internet Engineering Task Force RFC, the word FOO originated as a nonsense word with its earliest documented use in the 1930s comic Smokey Stover by Bill Holman.

Why is foo used in examples?

foo is used as a place-holder name, usually in example code to signify that the object being named, or the choice of name, is not part of the crux of the example. foo is often followed by bar , baz , and even bundy , if more than one such name is needed. Wikipedia calls these names Metasyntactic Variables.

What does foo and bar mean?

In the world of computer programming, "foo" and "bar" are commonly used as generic examples of the names of files, users, programs, classes, hosts, etc. Thus, you will frequently encounter them in manual (man) pages, syntax descriptions, and other computer documentation.


3 Answers

It's traditionally used for just a random name. Some other common ones are:

  1. Foo
  2. Bar
  3. Quux
  4. Baz

The supposed origin of foo and bar is that "FUBAR" was WWII slang for F***ed Up Beyond All Recognition. FUBAR => FOOBAR => Foo and Bar.

There isn't really a compelling reason to choose it besides the fact that no language reserves the word foo and that it's easy enough to type/read.

like image 92
Daniel Gratzer Avatar answered Oct 16 '22 03:10

Daniel Gratzer


foo is a term used to represent something without you getting too attached to the meaning. I could say object a in its place or literally anything else.

see examples 1 or 4 here: http://www.urbandictionary.com/define.php?term=foo

like image 26
ps2goat Avatar answered Oct 16 '22 03:10

ps2goat


It's a generic name for a thing, using in computer science in general. Etymologically, "foo" is the first syllable of "FUBAR", which is an acronym for "**ed Up Beyond All Recognition/Recovery".

like image 28
Beta Avatar answered Oct 16 '22 05:10

Beta