reorganizing_code
本文为"the art of readable code"一书的笔记
extracting unrelated subproblems
- 要封装一些和本功能无关的子问题到另外一个函数上。
- 对于一些工具的类或函数(字符串操作,哈希表等),就分离出来。
one task at a time
- 每个函数应该只实现一个功能,不要实现多个功能。
turning thoughts into code
- 记住爱因斯坦的这句话:
You do not really understanding something unless you can explain it to your grandmother. --Albert Einstein
- 代码应该用易懂的英语来写。
writing less code
- 一定要熟悉现存的库,这样可以减少代码量,多重用代码,少写代码。
- 使用Unix工具(shell命令),而不是自己写代码