如何使用 AI 生成的代码? 重点在于理解所生成的代码。
结构良好的代码可以被定义为容易修改的代码, 而容易修改的代码可以被定义为容易理解的代码。
可以用 AI 生成代码,但是一定要保证:
- 你可以理解所生成的代码。
- 所生成的代码易于理解。
否则项目很快就会失控。
可以用 AI 在生成代码的同时,来帮助我们达成上面两个目标。 比如,让 AI 总结代码的结构,写注释和例子,写开发日志,等等。
总结
所有 AI 生成的代码都需要被彻底理解。 除非有一天人类可以完全不出现在修改代码的 loop 中了。
当 AI 已经把很多信息加载到 context 中了, 利用这些 context 来让 AI 帮助你理解代码。 类似 "how to solve it" 的 look back。
Four phases
Trying to find the solution, we may repeatedly change our point of view, our way of looking at the problem. We have to shift our position again and again.
Our conception of the problem is likely to be rather incomplete when we start the work; our outlook is different when we have made some progress; it is again different when we have almost obtained the solution.
- (1) understand -- clarity
- (2) plan -- connections
- (3) carry out -- check each steps
- (4) look back -- to gain the most from our works
It is important to go through all the phases, to advance while avoiding obvious mistakes, and to gain the most from our works.