SlideShare a Scribd company logo
1 of 12
弯曲,或者折断
效 程实 编 3
Horky
7/Jun,2010
http://blog.csdn.net/horkychen
1
Keywords
• 化应对变 :
– 解耦 : 得墨忒尔法则
– 元数据与 配置动态
– 并 与次序发
– 分模 、分而治之划 块
• 编码时
– 不要靠巧合 程编
– 代 需要演化:重码 构
– 写易于 的代编 测试 码
2
得墨忒尔法则 (Demeter)
• 某个对象的任何方法都应该只能调用:
– 它自身
– 传入该方法的任何参数
– 它创建的任何对象
– 任何直接持有的组件对象
3
元数据与动态配置
• 将变化封装起来,使用元数据进行配置。
– 什么是变化的?
– 什么是不变化的?
– 抽象、抽象
4
并发与时序
• 时间耦合( temporal coupling)
– 定义好你的工作流
– 用服务为并发进行设计
– Windows COM+ 技术解说
5
分而治之
• 观察者模式
6
靠巧合编程
• 有时我们不知道为什么代码会有问题,因为我
们都不知道它为什么能工作。
• 几项注意:
– 它也许只是看起来能工作
– 你依靠的边界条件也许只是一个偶然
– 没有记入文档的行为可能会产生不必要的依赖
– 多余的和不必要的调用会成为代码的负担
– 多余的调用还会增加引入 BUG 的风险
• 简洁且高效的代码是我们的目标
• 在文档记录各种假定。大胆假设、小心论证。
7
深思熟虑的编程
• 总是意识到你在做什么
• 不要盲目地编程
• 按照计划行事
• 依据可靠的事物,不要依靠巧合和假定
• 为你的假定建立文档。(异常处理和断言)
• 不要只是测试你的代码,还要测试你的假定
• 为你的工作划分优先级
• 不要做历史的奴隶。不要让已有代码支配未来
的代码
8
代码需要演化
• 软件工程师与建筑师
• 软件工程师与园丁
9
如何进行重构
• 重构需要慎重、小心进行的活动,也需要
勇气:
– 不要试图在重构的同时增加新功能。
– 在开始之前,确保你拥有良好的测试。
– 采取短小、深思熟虑的步骤进行重构。
10
易于测试的代码
• 测试是 R&D 的责任!
• 保证我们清楚我们在做什么,并且做好了
。
– 单元测试及回归测试
– 例如 :Perl 的编译支持
• make test 进行回归测试
• 测试驱动开发
– ZOLO 4 将要求工程师在编写 FS 时生成 Check
list
11
Q&A
12

More Related Content

Viewers also liked

Google模式速览
Google模式速览Google模式速览
Google模式速览杰丰 余
 
我读《联盟》第一季
我读《联盟》第一季我读《联盟》第一季
我读《联盟》第一季杰丰 余
 
Jobmet total solution
Jobmet total solutionJobmet total solution
Jobmet total solutionJobmetbryanwu
 
程序员发展漫谈
程序员发展漫谈程序员发展漫谈
程序员发展漫谈Horky Chen
 
Google和apple招聘的那些事
Google和apple招聘的那些事Google和apple招聘的那些事
Google和apple招聘的那些事杰丰 余
 
注重实效的编程(2)
注重实效的编程(2)注重实效的编程(2)
注重实效的编程(2)Horky Chen
 
21 Tweets for Beginners
21 Tweets for Beginners21 Tweets for Beginners
21 Tweets for BeginnersBarry Feldman
 
我读《Google模式》全集
我读《Google模式》全集我读《Google模式》全集
我读《Google模式》全集杰丰 余
 
Social+digital+mobile recruiting-and-employer-branding-in-china2
Social+digital+mobile recruiting-and-employer-branding-in-china2Social+digital+mobile recruiting-and-employer-branding-in-china2
Social+digital+mobile recruiting-and-employer-branding-in-china2Au yung
 
大数据人才招聘
大数据人才招聘大数据人才招聘
大数据人才招聘杰丰 余
 
巧用佣金配合战略
巧用佣金配合战略巧用佣金配合战略
巧用佣金配合战略杰丰 余
 
Waterville Talent Platform 华迪人才管理系统 2012
Waterville Talent Platform 华迪人才管理系统 2012Waterville Talent Platform 华迪人才管理系统 2012
Waterville Talent Platform 华迪人才管理系统 2012y_james_song
 
Stabbing Mediocrity to Death
Stabbing Mediocrity to Death Stabbing Mediocrity to Death
Stabbing Mediocrity to Death Barry Feldman
 
How to Assemble a Results-Driven B2B Marketing Team
How to Assemble a Results-Driven B2B Marketing TeamHow to Assemble a Results-Driven B2B Marketing Team
How to Assemble a Results-Driven B2B Marketing TeamUberflip
 
Solar Systems By Tecso Projects Limited, Vadodara
Solar Systems By Tecso Projects Limited, VadodaraSolar Systems By Tecso Projects Limited, Vadodara
Solar Systems By Tecso Projects Limited, VadodaraIndiaMART InterMESH Limited
 
Rock and Roll Content: Creating Big Hits
Rock and Roll Content: Creating Big HitsRock and Roll Content: Creating Big Hits
Rock and Roll Content: Creating Big HitsBarry Feldman
 

Viewers also liked (17)

Google模式速览
Google模式速览Google模式速览
Google模式速览
 
我读《联盟》第一季
我读《联盟》第一季我读《联盟》第一季
我读《联盟》第一季
 
Jobmet total solution
Jobmet total solutionJobmet total solution
Jobmet total solution
 
程序员发展漫谈
程序员发展漫谈程序员发展漫谈
程序员发展漫谈
 
Google和apple招聘的那些事
Google和apple招聘的那些事Google和apple招聘的那些事
Google和apple招聘的那些事
 
注重实效的编程(2)
注重实效的编程(2)注重实效的编程(2)
注重实效的编程(2)
 
21 Tweets for Beginners
21 Tweets for Beginners21 Tweets for Beginners
21 Tweets for Beginners
 
我读《Google模式》全集
我读《Google模式》全集我读《Google模式》全集
我读《Google模式》全集
 
Social+digital+mobile recruiting-and-employer-branding-in-china2
Social+digital+mobile recruiting-and-employer-branding-in-china2Social+digital+mobile recruiting-and-employer-branding-in-china2
Social+digital+mobile recruiting-and-employer-branding-in-china2
 
大数据人才招聘
大数据人才招聘大数据人才招聘
大数据人才招聘
 
巧用佣金配合战略
巧用佣金配合战略巧用佣金配合战略
巧用佣金配合战略
 
Waterville Talent Platform 华迪人才管理系统 2012
Waterville Talent Platform 华迪人才管理系统 2012Waterville Talent Platform 华迪人才管理系统 2012
Waterville Talent Platform 华迪人才管理系统 2012
 
Stabbing Mediocrity to Death
Stabbing Mediocrity to Death Stabbing Mediocrity to Death
Stabbing Mediocrity to Death
 
How to Assemble a Results-Driven B2B Marketing Team
How to Assemble a Results-Driven B2B Marketing TeamHow to Assemble a Results-Driven B2B Marketing Team
How to Assemble a Results-Driven B2B Marketing Team
 
Solar Systems By Tecso Projects Limited, Vadodara
Solar Systems By Tecso Projects Limited, VadodaraSolar Systems By Tecso Projects Limited, Vadodara
Solar Systems By Tecso Projects Limited, Vadodara
 
Rock and Roll Content: Creating Big Hits
Rock and Roll Content: Creating Big HitsRock and Roll Content: Creating Big Hits
Rock and Roll Content: Creating Big Hits
 
The Anatomy of The Perfect Coffee Break
The Anatomy of The Perfect Coffee BreakThe Anatomy of The Perfect Coffee Break
The Anatomy of The Perfect Coffee Break
 

More from Horky Chen

编程语言与自然语言
编程语言与自然语言编程语言与自然语言
编程语言与自然语言Horky Chen
 
Tow points of WebKit in design
Tow points of WebKit in designTow points of WebKit in design
Tow points of WebKit in designHorky Chen
 
代码大全(内训)
代码大全(内训)代码大全(内训)
代码大全(内训)Horky Chen
 
程序员实践之路
程序员实践之路程序员实践之路
程序员实践之路Horky Chen
 
Java scriptcore brief introduction
Java scriptcore brief introductionJava scriptcore brief introduction
Java scriptcore brief introductionHorky Chen
 
JavaScript closures
JavaScript closuresJavaScript closures
JavaScript closuresHorky Chen
 

More from Horky Chen (6)

编程语言与自然语言
编程语言与自然语言编程语言与自然语言
编程语言与自然语言
 
Tow points of WebKit in design
Tow points of WebKit in designTow points of WebKit in design
Tow points of WebKit in design
 
代码大全(内训)
代码大全(内训)代码大全(内训)
代码大全(内训)
 
程序员实践之路
程序员实践之路程序员实践之路
程序员实践之路
 
Java scriptcore brief introduction
Java scriptcore brief introductionJava scriptcore brief introduction
Java scriptcore brief introduction
 
JavaScript closures
JavaScript closuresJavaScript closures
JavaScript closures
 

注重实效的编程(3)