• All right, those pieces of code inherently involved something that does depend on the size of the input, or on the particular input.

    好,这些代码,肯定会涉及到一些,与输入的大小相关的东西,或者说与特定输入相关。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • Which is a way of reminding you that I need to think as I write the code about what are my expectations from the input, and how might I enforce them.

    通过这个我在提醒大家,在写代码的时候,要搞清楚对输入的期望,并思考下如何执行这些期望。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • Because if I don't specify a name for this input, I have no way of actually referring to it in subsequent lines of code.

    因为如果我不给这个输入定义一个名字,在随后的代码中,我就没有办法使用它。

    哈佛公开课 - 计算机科学课程节选

  • The only thing I've done in this part of the program, now I'm going to go and read the code, is I've gotten the user to input a bunch of data.

    现在我去读读这里的代码,是我会让用户输入一些数据,然后根据用户输入的数据。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • I'm much better having an exception get handled at the time of input than to let that prop -- that value rather propagate through a whole bunch of code until eventually it hits an error 17 calls later, and you have no clue where it came from.

    不是我期望的格式,这时我最好有一个异常处理,而不是让其传下去,这个值传到代码的整个分支,最终会导致一个错误17调用的发生,并且你不知道这个错误是哪里来的。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • If I decide there's a better way to get input, and there is, then I can make it to change what I don't have to change the code that uses the input.

    如果我觉得有更好的获取输入的方法,我可以直接改去用这种方式,而不用更改使用了,输入处的代码。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • So, summarizing better, assert is something you put in to say to the user, make sure you're giving me input of this type, but I'm going to guarantee you the rest of the code works correctly. Exceptions and exception handlers are saying, here are the odd cases that I might see and here's what I'd like to do in those cases in order to try and be able to deal with them.

    所以更好的总结下,断言就是你放在那里告诉用户,保证你输入的是这种类型的,但我能保证剩下的代码运行正确,异常和异常处理做的事,这里有些我能预期的异常情况,并且这里有些情况,我能尝试处理。

    麻省理工公开课 - 计算机科学及编程导论课程节选

$firstVoiceSent
- 来自原声例句
小调查
请问您想要如何调整此模块?

感谢您的反馈,我们会尽快进行适当修改!
进来说说原因吧 确定
小调查
请问您想要如何调整此模块?

感谢您的反馈,我们会尽快进行适当修改!
进来说说原因吧 确定