what does "foo" and "bar" mean and why people like use them as example case?

huangapple go评论70阅读模式
英文:

what does "foo" and "bar" mean and why people like use them as example case?

问题

在许多程序测试用例或示例中,我经常看到"bar"和"foo"这两个词,这两个词代表什么,为什么选择这两个词作为示例?

英文:

In many program test case or example case, i always see "bar" and "foo", what is the two word represent for and why choose this two words as example?

答案1

得分: 3

谷歌可以比我更好地回答你的问题。根据维基百科

"Foo"一词起源于20世纪30年代的一个无意义的词,军事术语FUBAR出现在20世纪40年代,而在编程环境中使用"foo"一词通常归功于麻省理工学院的Tech Model Railroad Club(TMRC)约在1960年左右。然而,这些术语之间的确切关系尚不确定,并且有几种传闻理论被提出来解释它们的起源。

另外,你可以查看这个问题:https://stackoverflow.com/questions/4868904/what-is-the-origin-of-foo-and-bar,以及这个问题:https://softwareengineering.stackexchange.com/questions/69788/what-is-the-history-of-the-use-of-foo-and-bar-in-source-code-examples

英文:

Google can answer your question far better than I. From wiki:

> The word foo originated as a nonsense word from the 1930s, the military term FUBAR emerged in the 1940s, and the use of foo in a programming context is generally credited to the Tech Model Railroad Club (TMRC) of MIT from circa 1960.[9] However, the precise relationship of these terms is not known with certainty, and several anecdotal theories have been advanced to identify them.

Also, have a look at this question: https://stackoverflow.com/questions/4868904/what-is-the-origin-of-foo-and-bar as well as this one: https://softwareengineering.stackexchange.com/questions/69788/what-is-the-history-of-the-use-of-foo-and-bar-in-source-code-examples

huangapple
  • 本文由 发表于 2016年1月22日 16:25:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/34942101.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定