程序开发之“道”

程序开发之“道”

1) “有之以为利,无之以为用。”“What has a (positive) existence serves for profitable adaptation, and what has not that for (actual) usefulness.”

世界上最高效、最健壮、最易维护的代码就是不存在的那部分代码。这部分代码不占用运行时间、不会被破解攻击、不需要任何维护。所以,三思而后行,一个良好的设计可以减少很多代码,也就减少了很多麻烦。
The most efficient, securest, and most maintainable codes are those which do not exist. They cost no time, they are unbreakable, and they do not need any maintenance. Do think more before you do, a better design can save you a lot of trouble.

2) “持而盈之不如其己;揣而锐之不可长保”“It is better to leave a vessel unfilled, than to attempt to carry it when it is full. If you keep feeling a point that has been sharpened, the point cannot long preserve its sharpness.”

不要过度设计,刚开始只要设计到刚好能用。复杂而强大的设计的生命往往短命,而简单的设计大多实用而经久不衰。额外的复杂设计看起来很好,但很可能这些额外的功能在这个设计被抛弃前根本不会被用到,但你已经浪费了很多时间来实现和调试这些功能。
Do not over design. Make it just work at first. A powerful yet complex design usually lives much shorter than a simple one. And there’s a great chance that the extra power will never be used, although it takes much longer to implement and debug.

3) “上士闻道勤而行之。中士闻道若存若亡。下士闻道大笑之。”“Scholars of the highest class, when they hear about the Tao, earnestly carry it into practice. Scholars of the middle class, when they have heard about it, seem now to keep it and now to lose it. Scholars of the lowest class, when they have heard about it, laugh greatly at it.”

好的设计看起来很简单、很单纯。但其实,为复杂的系统做出一个简单的设计是件很不容易的事。
Good code looks simple, stupid. And it is hard to make a complex system look simple.

4) “以正治国,以奇用兵”“A state may be ruled by (measures of) correction; weapons of war may be used with crafty dexterity.”

好的设计能够让程序员以正常直观的方式写出程序。但有时我们不得不做一些hack的操作以获得足够的效率或实现特殊的功能。这些hack应该是局部并且隐匿的。
A good design let programmers do most things in a normal way. But sometimes we cannot do without a hack. The hacks should be local and not easy to be aware of. Appropriate use of hack can double the returns.
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值