到foo吧,还是不foo吧:这就是问题 [英] To foo bar, or not to foo bar: that is the question

查看:200
本文介绍了到foo吧,还是不foo吧:这就是问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是最初讨论的问题,由Charles Brian Quinn在大书呆子牧场的演示中< a href =http://www.actsasconference.com =nofollow noreferrer> acts_as_conference 。他正在讨论他从指导Ruby on Rails Bootcamp所学到的许多人对编程和Rails的新习惯。

This was something originally discussed during a presentation given by Charles Brian Quinn of the Big Nerd Ranch at acts_as_conference. He was discussing what he had learned from instructing a Ruby on Rails Bootcamp to many people both new to programming and new to Rails.

一个特别的幻灯片是沿着从不使用foo和bar作为示例,试图教某人编程。他的推理很简单。

One particular slide that stood out was along the lines of never using foo and bar as examples when trying to teach someone to program. His reasoning was very simple.

这更容易理解吗?

baz = foo + bar

answer = first_number + second_number

解释一些东西,我立即跳到去foo酒吧占位符,但然后实现我的错误,使示例通过使用一个真实世界的场景更有意义。

It's happened many times myself when explaining something and I immediately jump to the go to foo bar placeholders but then realize my mistake and make the example make a lot more sense by using a real world scenario.

这是特别适用于试图教一个没有编程风险的人,最后需要解释foo和bar,然后才解释你实际上想教什么。

This is especially applicable when trying to teach someone who has had no programming exposure and you end up needing explain foo and bar before explaining what you're actually trying to teach.

但是,对于有经验的程序员使用foo和bar似乎没问题,虽然我个人认为,与Charles一起,这是需要改变的。

However, using foo and bar for experienced programmers seems OK, though I personally think, along with Charles, that it's something that needs to change.

快速搜索foo返回超过20页的结果,foo以我能理解的更多方式使用。在某些情况下,我正在阅读一个特定语言的问题,我这样做有助于更好地理解这种语言。如果使用适用的变量名称而不是foo和bar,它使它更容易理解和解释问题。因此,对于经验丰富的开发者来说,这个结构似乎也有一些缺陷。

A quick SO search for "foo" returns over 20 pages of results with foo being used in more ways that I can comprehend. And in some cases where I'm reading a question on a particular language and I'm doing so to help understand that language better. If applicable variable names are used instead of foo and bar, it makes it much easier to understand and interpret the problem. So for seasoned developers, the construct seems a bit flawed as well.

这是一个可以被踢的习惯吗?你为什么选择foo bar或不选foo bar?

Is this a habit that will ever be able to be kicked? Why do you choose to foo bar or to not foo bar?

推荐答案

这完全取决于你想教什么。有时,当显示一个编程示例时,您必须声明几个只是为了完成的片段,这些少数事情不是你显示的核心。

It strictly depends on what are you trying to teach. Sometimes, when showing a programming example, you have to declare a few things just for the snippet to be "complete", and those few things are not the core of what you are showing.

例如,如果您想要显示如何抛出异常,我相信可以提交像

For example, if you want to show how to throw an exception, I believe it is ok to present a snippet like

public void foo() { 

   // Do some things

   if (errorCondition) {
      throw new Exception("Error message");
   }

}

例外,关心方法名称没有意义,所以foo在这种情况下是合法的,或至少对我来说。

Since the point in it is showing exceptions, there is no point in caring about the method name, so foo is "legal" in this context, or at least for me.

我不接受在这个例子中)是

What I would not accept (in this same example) would be

public void foo() { 

   // Do some things

   if (bar) {
      throw new Exception(baz);
   }

}

试图教学。

这篇关于到foo吧,还是不foo吧:这就是问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆