Andy's Life Lessons for Working on Code

CMU database group 的 Andy Palvo 老师,在 17 年的数据库课程上讲了这样一则小事:

他问一位工业界的朋友,你想要招到怎么样的学生?那位朋友回答说,我最希望找到的学生是,如果我直接 Memcachd 代码给他(他以前并没有接触过 Memcachd 的代码),他能在两三个小时内实现一个功能(不管这个功能 trivial 与否)。

听到这里,感触挺深的。现在在到处都是开源代码,code base 越来越庞大,我们如果能够直接单挑它们,那必然在作为程序员的路上走得比别人更加远。

后面他分享了自己对于 “Working on Large Code Base” 的一些经验,在这里总结下,与君共享。

PASSIVE READING

Reading the code for the sake of reading code is (usually) a waste of time.
It's import to start woking the code right away to understand how it works.

不要单纯为读代码而读代码,理解代码最好的方式是对代码进行些改动,改改、跑跑、想想,这样才能对代码有更好的理解。

TEST CASES

Adding or improving tests allows you to improve the reliability of the code base without the risk of breaking production code.

改改代码经济,有效的办法是给项目增加一些 test case。

REFACTORING

Find the general location of code that you want to work on and start cleaning it up.

  • Add/edit comments
  • Clean up messy code
  • Break out repeated logic into separate functions

给代码做些小的重构。个人感觉从理解代码的层面上来说,前面说的给代码加些 test case 效果更佳。

TOOLCHAINS & PROCESSES

Beyond working on the code, there will also be an established protocol for software development.
More established projects will have either training or comprehensive documentation.

  • If the documentation isn't available, then you can take the initiative and try to write it.

从项目相关的工具,文档入手。

你可能感兴趣的:(Andy's Life Lessons for Working on Code)