或许这种微妙的心理定位可以解释:为什么程序员进入新项目组后宁愿丢掉旧代码重新写,也不愿意修修补补,他们认为旧代码简直一团糟。
但是,事实上真是这样吗?你之所以认为旧代码一团糟,其实是由编程的一个基本定律决定的,那就是:写代码容易,读代码难。
为什么你觉得旧代码异常混乱?因为读代码更难
这大概就是代码Reuse难以实现的原因,也可以解释为什么你组里的每个人都喜欢用不同的功能将分割的字符串转换成一个数组。比起猜测旧的功能是怎样实现的,重新写一个自己的功能要简单和有趣多了。
作为这个公理的推论,你可以问问身边的程序员他们正在奋战的代码怎么样?"简直是一塌糊涂!"他们肯定会这样说。"我简直想推倒重来!"
Read full article from 程序员,为什么千万不要重写代码? | 程序师
No comments:
Post a Comment