• So there's a return branch on every possible path through the code. And that's valuable, it's something you want to think about as your right your own.

    所以代码条可能的路径,都会有一个返回值分支,这是非常有价值的,当你自己写程序的时候也应该考虑这件事。

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

  • First one, when I write a piece of code, especially code that has branches in it, when I design test cases for that piece of code, I should try and have a specific test case for each possible path through the code.

    第一点,当我们写代码的时候,尤其是一些含有分支语句的代码的时候,当我为这些代码,设计测试用例的时候,我应该为一个可能的程序路径,都设计一个特别的用例。

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

  • If it does, then execute each of the instructions in that block.

    这块代码内的,一个指令。

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

  • Count the number of primitive operations in each step.

    数一数一步中的基本操作,好的,如果我们看看这段代码

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

  • OK. Note, by the way, if I chase through each possible path, like there's some IFs in here, if there's some places to go, at least in this piece of code, every possible path through this code ends in a return. And that's a good programming discipline, to make sure that happens.

    注意一下,如果我跟进一条可能的路径,像是这里的,起码在这段代码中就有很多走向,这段代码中的一条可能路径,在结尾都会返回一个值,这就是一条很好的编程定律,请确保这样做。

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

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

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

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