当foo和bar不够时

时间:2021-02-16 04:08:42

When you are using placeholder names when programming (not necessary variable names, but labels, mockup names, etc) and foo and bar is not enough, what do you use?

当您在编程时使用占位符名称(不是必需的变量名称,但标签,模型名称等)和foo和bar是不够的时候,您使用什么?

I guess baz is rather common as third name, and the lorem ipsum for longer texts. But then what?

我猜baz作为第三个名字很常见,而lorem ipsum则是较长的文本。但那又怎样?

26 个解决方案

#1


From Wikipedia:

A "standard list of metasyntactic variables used in syntax examples" is: foo, bar, baz, qux, quux, corge, uier, grault, garply, waldo, fred, plugh, thud, mos, henk, def.

“语法示例中使用的标准变量的标准列表”是:foo,bar,baz,qux,quux,corge,uier,grault,garply,waldo,fred,plugh,thud,mos,henk,def。

#2


If an example is that complex, it would probably be easier to understand if you just used real variable names.

如果一个例子就是那么复杂,那么如果你只使用真正的变量名,可能会更容易理解。

#3


For arbitrary names beyond bar, I've always gone with inky, pinky, blinky, and in exceptional cases, clyde.

对于超越酒吧的任意名字,我总是带着墨,小指,眨眼,在特殊情况下,克莱德。

#4


Here's the jargon file entry on metasyntactic variables.

这是关于metasyntactic变量的行话文件条目。

#5


in France we use "toto", "tata", "titi" etc... instead of foo and bar... ("tyty" is rarely used)

在法国,我们使用“toto”,“tata”,“titi”等...而不是foo和bar ......(很少使用“tyty”)

#6


Names of swedish vegetables and fruits: gurka, tomat, banan. Bonus points if you have å, ä, or ö in the variable names. :-)

瑞典蔬菜和水果的名称:gurka,tomat,banan。如果您在变量名称中有å,ä或ö,则可获得奖励积分。 :-)

#7


foo, baz and bar are enough. For total confusion you can combine them into foobar, foobazbar, bazfoo, foofoo and so on.

foo,baz和bar就足够了。对于完全混乱,你可以将它们组合成foobar,foobazbar,bazfoo,foofoo等。

#8


I always like:

我总是喜欢:

  • asdf
  • qwer
  • uiop

Because they are all a quick flick of one hand over all fingers, not far from your home position, and you can pronounce them (as opposed to zxcv and jkl which don't roll off the tongue quite as well :)

因为它们都是一只手快速轻弹所有手指,离你家的位置不远,你可以发音(而不是zxcv和jkl,它们也不会松开舌头:)

FWIW Common lisp has a package manager called asdf

FWIW Common lisp有一个名为asdf的包管理器

#9


moo, cow, sheep, baa (in that order).

moo,牛,羊,baa(按此顺序)。

#10


People at my work have a curious affinity for "monkey"

我工作的人对“猴子”有着好奇的亲和力

#11


It's probably a better habit to use names related to the problem, since this will aid communication.

使用与问题相关的名称可能是一个更好的习惯,因为这有助于沟通。

But in cases where you are working in the abstract and really don't want the names to matter, there are lists of commonly-used metasyntactic variables available in the Jargon File (which lists several different progressions) or from Wikipedia (currently "foo, bar, baz, qux, quux, corge, uier, grault, garply, waldo, fred, plugh, thud, mos, henk, def").

但是如果您正在抽象地工作并且实际上不希望名称重要,那么Jargon文件(列出几个不同的进展)或*(目前为“foo”)中提供常用的元语法变量列表。 bar,baz,qux,quux,corge,uier,grault,garply,waldo,fred,plugh,thud,mos,henk,def“)。

Personally, I've never seen or used most of the unpronounceable words in those lists, but I have seen and prefer to use "foo, bar, baz, spam, fred, xyzzy."

就个人而言,我从未在这些列表中看到或使用过大多数不可发音的单词,但我已经看过并且更喜欢使用“foo,bar,baz,spam,fred,xyzzy”。

Ultimately, any set of nonsense words should work, or any set of words that are nonsensical relative to the problem.

最终,任何一组无意义的单词都应该起作用,或者任何与该问题无关的单词。

Some folks I know get really sick of foo, bar, et al., so an alternative is to use character names from TV shows. I frequently use "Fred, Barney, Wilma, Betty, Pebbles, BammBamm." This is particularly useful in abstract OO discussions, because "Fred is-a Flintstone" comes across pretty clearly.

我认识的一些人真的厌倦了foo,bar等人,所以另一种选择是使用电视节目中的角色名称。我经常使用“Fred,Barney,Wilma,Betty,Pebbles,BammBamm。”这在抽象的OO讨论中特别有用,因为“Fred is-a Flintstone”非常清楚。

#12


What's wrong with x, y, z? Or a, b, c?

x,y,z有什么问题?或者a,b,c?

#13


My favourites in German are “wilde” and “wutz”, in conjunction, which could be translated as “wild” and “piglet”. Also, there's “barfoos”, which, when spoken, sounds like “barfuß”, German for “barefoot”.

我最喜欢的德语是“wilde”和“wutz”,它们可以翻译成“野生”和“小猪”。此外,还有“barfoos”,当说出来时,听起来像“barfuß”,德语是“赤脚”。

#14


I've also seen fee, fie, foe, fum.

我也见过费,f,敌,fum。

#15


In Expert C Programming: Deep Secrets, Peter van der Linden used vegetables.

在Expert C Programming:Deep Secrets中,Peter van der Linden使用了蔬菜。

#16


and for OOP Thingoid...

并为OOP Thingoid ...

#17


After foo, bar, baz and qux, which are the only canonical ones I can remember, I tend to use "META_SYNTACTIC_VARIABLE_1", "META_SYNTACTIC_VARIABLE_2", or just "$VAR1", "$VAR2" and so on.

在foo,bar,baz和qux之后,这是我记忆中唯一的规范,我倾向于使用“META_SYNTACTIC_VARIABLE_1”,“META_SYNTACTIC_VARIABLE_2”,或者只是“$ VAR1”,“$ VAR2”等等。

#18


Pick a theme and use it.

选择一个主题并使用它。

Or use CPAN's ACME::MetaSyntactic to generate them for you. Lots of themes out of the box.

或者使用CPAN的ACME :: MetaSyntactic为您生成它们。很多主题开箱即用。

#19


imagination

#20


When writing code examples in Stack Overflow, I prefer using the "My" prefix; that is

在Stack Overflow中编写代码示例时,我更喜欢使用“My”前缀;那是

  • MyClass
  • MyInstance
  • MyEnumerator
  • MySingleton

You get the idea. The adventage of this approach is that everyone knows what you are talking about without going into the details too much or distracting the attention from the topic. (P.S. normally I hate the My prefix, like in "My Computer" or MySQL but I think it fits this scenario)

你明白了。这种方法的冒险之处在于,每个人都知道你在谈论什么,而不会过多地关注细节或分散对主题的注意力。 (P.S.通常我讨厌我的前缀,比如“我的电脑”或MySQL,但我认为它适合这种情况)

#21


I often go to blah after foo and bar. I usually stop there.

经常在foo和bar之后去等等。我经常在那里停下来。

#22


I often use "aap", "noot", "mies", from the "Leesplankje van Hoogeveen" (The page is in Dutch only, but I'll try to explain it. It's a board with simple words and pictures for teaching children to read and more importantly all the different vowels Dutch has. The last version of the board contains 18 vowels, most of them consist of different combinations of the 'vowel letters'. I'm not sure if it's seriously used in education, but it's IMHO a great piece of Dutch cultural history)

我经常使用“Leesplankje van Hoogeveen”中的“aap”,“noot”,“mies”(该页面只有荷兰语,但我会尝试解释它。这是一个简单的单词和图片用于教孩子的板子阅读,更重要的是所有不同的荷兰元音。最后一个版本的电路板包含18个元音,其中大部分由“元音字母”的不同组合组成。我不确定它是否在教育中被认真使用,但它是恕我直言,荷兰文化史上的一大部分)

#23


If you find you need more names beyond baz, it probably means the mockup is getting too complicated and these names will actually make it more difficult to follow the example code. I'd just rename the symbols to use meaningful names.

如果您发现除了baz之外还需要更多名称,这可能意味着模型变得过于复杂,这些名称实际上会使遵循示例代码变得更加困难。我只是重命名符号以使用有意义的名称。

(I'm not even considering the case where the throw-away code is becoming production code with all the foos and bars in it. I'm sure it never ever happens. Or else.)

(我甚至没有考虑丢失代码变成生产代码的情况,其中包含所有的foos和bar。我相信它永远不会发生。或者其他。)

Finally, not exactly conventionals yet, but here's my Turkish contributions: hede, hodo, budu & zart.

最后,不完全是常规,但这是我的土耳其贡献:hede,hodo,budu&zart。

#24


In Italy, Disney characters are faves: Pippo, Paperino, Topolino, (resp. Goofy, Donald, Mickey). Italy is, or was, the second country in Disney Popularity after the USA.

在意大利,迪斯尼人物很喜欢:Pippo,Paperino,Topolino,(分别是Goofy,Donald,Mickey)。意大利是继美国之后的第二个迪士尼人气国家。

#25


I typically use single-letter placeholder variable names, and strings like "This is a button" or "Here is some text" / "here is more of it" for UI stuff.

我通常使用单字母占位符变量名称,以及像“这是一个按钮”或“这里是一些文本”/“这里更多的”字符串用于UI的东西。

#26


I use the Greek alphabet, but I rarely go past delta.

我使用希腊字母表,但我很少超过三角洲。

#1


From Wikipedia:

A "standard list of metasyntactic variables used in syntax examples" is: foo, bar, baz, qux, quux, corge, uier, grault, garply, waldo, fred, plugh, thud, mos, henk, def.

“语法示例中使用的标准变量的标准列表”是:foo,bar,baz,qux,quux,corge,uier,grault,garply,waldo,fred,plugh,thud,mos,henk,def。

#2


If an example is that complex, it would probably be easier to understand if you just used real variable names.

如果一个例子就是那么复杂,那么如果你只使用真正的变量名,可能会更容易理解。

#3


For arbitrary names beyond bar, I've always gone with inky, pinky, blinky, and in exceptional cases, clyde.

对于超越酒吧的任意名字,我总是带着墨,小指,眨眼,在特殊情况下,克莱德。

#4


Here's the jargon file entry on metasyntactic variables.

这是关于metasyntactic变量的行话文件条目。

#5


in France we use "toto", "tata", "titi" etc... instead of foo and bar... ("tyty" is rarely used)

在法国,我们使用“toto”,“tata”,“titi”等...而不是foo和bar ......(很少使用“tyty”)

#6


Names of swedish vegetables and fruits: gurka, tomat, banan. Bonus points if you have å, ä, or ö in the variable names. :-)

瑞典蔬菜和水果的名称:gurka,tomat,banan。如果您在变量名称中有å,ä或ö,则可获得奖励积分。 :-)

#7


foo, baz and bar are enough. For total confusion you can combine them into foobar, foobazbar, bazfoo, foofoo and so on.

foo,baz和bar就足够了。对于完全混乱,你可以将它们组合成foobar,foobazbar,bazfoo,foofoo等。

#8


I always like:

我总是喜欢:

  • asdf
  • qwer
  • uiop

Because they are all a quick flick of one hand over all fingers, not far from your home position, and you can pronounce them (as opposed to zxcv and jkl which don't roll off the tongue quite as well :)

因为它们都是一只手快速轻弹所有手指,离你家的位置不远,你可以发音(而不是zxcv和jkl,它们也不会松开舌头:)

FWIW Common lisp has a package manager called asdf

FWIW Common lisp有一个名为asdf的包管理器

#9


moo, cow, sheep, baa (in that order).

moo,牛,羊,baa(按此顺序)。

#10


People at my work have a curious affinity for "monkey"

我工作的人对“猴子”有着好奇的亲和力

#11


It's probably a better habit to use names related to the problem, since this will aid communication.

使用与问题相关的名称可能是一个更好的习惯,因为这有助于沟通。

But in cases where you are working in the abstract and really don't want the names to matter, there are lists of commonly-used metasyntactic variables available in the Jargon File (which lists several different progressions) or from Wikipedia (currently "foo, bar, baz, qux, quux, corge, uier, grault, garply, waldo, fred, plugh, thud, mos, henk, def").

但是如果您正在抽象地工作并且实际上不希望名称重要,那么Jargon文件(列出几个不同的进展)或*(目前为“foo”)中提供常用的元语法变量列表。 bar,baz,qux,quux,corge,uier,grault,garply,waldo,fred,plugh,thud,mos,henk,def“)。

Personally, I've never seen or used most of the unpronounceable words in those lists, but I have seen and prefer to use "foo, bar, baz, spam, fred, xyzzy."

就个人而言,我从未在这些列表中看到或使用过大多数不可发音的单词,但我已经看过并且更喜欢使用“foo,bar,baz,spam,fred,xyzzy”。

Ultimately, any set of nonsense words should work, or any set of words that are nonsensical relative to the problem.

最终,任何一组无意义的单词都应该起作用,或者任何与该问题无关的单词。

Some folks I know get really sick of foo, bar, et al., so an alternative is to use character names from TV shows. I frequently use "Fred, Barney, Wilma, Betty, Pebbles, BammBamm." This is particularly useful in abstract OO discussions, because "Fred is-a Flintstone" comes across pretty clearly.

我认识的一些人真的厌倦了foo,bar等人,所以另一种选择是使用电视节目中的角色名称。我经常使用“Fred,Barney,Wilma,Betty,Pebbles,BammBamm。”这在抽象的OO讨论中特别有用,因为“Fred is-a Flintstone”非常清楚。

#12


What's wrong with x, y, z? Or a, b, c?

x,y,z有什么问题?或者a,b,c?

#13


My favourites in German are “wilde” and “wutz”, in conjunction, which could be translated as “wild” and “piglet”. Also, there's “barfoos”, which, when spoken, sounds like “barfuß”, German for “barefoot”.

我最喜欢的德语是“wilde”和“wutz”,它们可以翻译成“野生”和“小猪”。此外,还有“barfoos”,当说出来时,听起来像“barfuß”,德语是“赤脚”。

#14


I've also seen fee, fie, foe, fum.

我也见过费,f,敌,fum。

#15


In Expert C Programming: Deep Secrets, Peter van der Linden used vegetables.

在Expert C Programming:Deep Secrets中,Peter van der Linden使用了蔬菜。

#16


and for OOP Thingoid...

并为OOP Thingoid ...

#17


After foo, bar, baz and qux, which are the only canonical ones I can remember, I tend to use "META_SYNTACTIC_VARIABLE_1", "META_SYNTACTIC_VARIABLE_2", or just "$VAR1", "$VAR2" and so on.

在foo,bar,baz和qux之后,这是我记忆中唯一的规范,我倾向于使用“META_SYNTACTIC_VARIABLE_1”,“META_SYNTACTIC_VARIABLE_2”,或者只是“$ VAR1”,“$ VAR2”等等。

#18


Pick a theme and use it.

选择一个主题并使用它。

Or use CPAN's ACME::MetaSyntactic to generate them for you. Lots of themes out of the box.

或者使用CPAN的ACME :: MetaSyntactic为您生成它们。很多主题开箱即用。

#19


imagination

#20


When writing code examples in Stack Overflow, I prefer using the "My" prefix; that is

在Stack Overflow中编写代码示例时,我更喜欢使用“My”前缀;那是

  • MyClass
  • MyInstance
  • MyEnumerator
  • MySingleton

You get the idea. The adventage of this approach is that everyone knows what you are talking about without going into the details too much or distracting the attention from the topic. (P.S. normally I hate the My prefix, like in "My Computer" or MySQL but I think it fits this scenario)

你明白了。这种方法的冒险之处在于,每个人都知道你在谈论什么,而不会过多地关注细节或分散对主题的注意力。 (P.S.通常我讨厌我的前缀,比如“我的电脑”或MySQL,但我认为它适合这种情况)

#21


I often go to blah after foo and bar. I usually stop there.

经常在foo和bar之后去等等。我经常在那里停下来。

#22


I often use "aap", "noot", "mies", from the "Leesplankje van Hoogeveen" (The page is in Dutch only, but I'll try to explain it. It's a board with simple words and pictures for teaching children to read and more importantly all the different vowels Dutch has. The last version of the board contains 18 vowels, most of them consist of different combinations of the 'vowel letters'. I'm not sure if it's seriously used in education, but it's IMHO a great piece of Dutch cultural history)

我经常使用“Leesplankje van Hoogeveen”中的“aap”,“noot”,“mies”(该页面只有荷兰语,但我会尝试解释它。这是一个简单的单词和图片用于教孩子的板子阅读,更重要的是所有不同的荷兰元音。最后一个版本的电路板包含18个元音,其中大部分由“元音字母”的不同组合组成。我不确定它是否在教育中被认真使用,但它是恕我直言,荷兰文化史上的一大部分)

#23


If you find you need more names beyond baz, it probably means the mockup is getting too complicated and these names will actually make it more difficult to follow the example code. I'd just rename the symbols to use meaningful names.

如果您发现除了baz之外还需要更多名称,这可能意味着模型变得过于复杂,这些名称实际上会使遵循示例代码变得更加困难。我只是重命名符号以使用有意义的名称。

(I'm not even considering the case where the throw-away code is becoming production code with all the foos and bars in it. I'm sure it never ever happens. Or else.)

(我甚至没有考虑丢失代码变成生产代码的情况,其中包含所有的foos和bar。我相信它永远不会发生。或者其他。)

Finally, not exactly conventionals yet, but here's my Turkish contributions: hede, hodo, budu & zart.

最后,不完全是常规,但这是我的土耳其贡献:hede,hodo,budu&zart。

#24


In Italy, Disney characters are faves: Pippo, Paperino, Topolino, (resp. Goofy, Donald, Mickey). Italy is, or was, the second country in Disney Popularity after the USA.

在意大利,迪斯尼人物很喜欢:Pippo,Paperino,Topolino,(分别是Goofy,Donald,Mickey)。意大利是继美国之后的第二个迪士尼人气国家。

#25


I typically use single-letter placeholder variable names, and strings like "This is a button" or "Here is some text" / "here is more of it" for UI stuff.

我通常使用单字母占位符变量名称,以及像“这是一个按钮”或“这里是一些文本”/“这里更多的”字符串用于UI的东西。

#26


I use the Greek alphabet, but I rarely go past delta.

我使用希腊字母表,但我很少超过三角洲。