ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Section3 Programs are Function Plus Variable Definitions

Section3 Programs are Function Plus Variable Definitions

翻译 Linux操作系统 作者:wq_brilliant 时间:2016-06-15 11:06:08 0 删除 编辑
Section3 -> http://www.htdp.org/2003-09-26/Book/curriculum-Z-H-6.html

上一章介绍了如何定义和调用简单的函数(一个函数已经能解决整个问题了),这一章更进一步,当遇到一个比较大的问题,比如说有很多依赖关系存在的时候,要注意分解大的问题为一个个小的问题。作者举了个例子,“如何定票价”,把没有分解问题直接写出的代码和分解后写的代码做了个对比(代码排版有问题,直接戳原文链接看。)
由此,给出第一条指南( the first and most important guide of programming )

Guideline on Auxiliary Functions

Formulate auxiliary function definitions for every dependency between quantities mentioned in the problem statement or discovered with example calculations.


说起来就一句话,做起来可没那么容易.

再出给关于变量定义的第二条指南

Guideline on Variable Definitions

Give names to frequently used constants and use the names instead of the constants in programs.


====================================
总结:
本章没有介绍新语法;提出了两条指南;给出了大量练习题。

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29000138/viewspace-2120182/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: Chapter 1, 2 Answer
请登录后发表评论 登录
全部评论

注册时间:2014-12-27

  • 博文量
    6
  • 访问量
    3338