SlideShare une entreprise Scribd logo
1  sur  24
Télécharger pour lire hors ligne
Refactoring
   dreampuf
Insight
Compare
400
      UbbParser
      nutshell/gksite/views_index
320   Text2pic
      Django:core/cache/backend/memcache

240


160


80


 0
            SLOC
8   UbbParser
    nutshell/gksite/views_index
    Text2pic
    Django:core/cache/backend/memcache
6



4



2



0
    maxBlockDepth
300
      UbbParser
      nutshell/gksite/views_index
240   Text2pic
      Django:core/cache/backend/memcache

180


120


60


 0
         numBlocks
50
              UbbParser
              nutshell/gksite/views_index

40            Text2pic
              Django:core/cache/backend/memcache


30


20


10


0
     DocString(%)
一种修改,使软件的内部结构更容易理解,在不改
变软件的可见行为方式前提下使软件更容易变更…
它是一种有节制的整理代码、使bug产生几率最小
化的方法。

           - Martin Fowler & Kent Beck
设计原则
设计原则
OCP open-closed principle
SRP single responsibility principle
ISP interface segregation principle
LSP Liskov substitution principle
DIP dependency inversion principle
坏味道
坏味道
重复
过长函数
过长的参数列表
散弹式修改
耦合
为未来着想太多
低内聚
测试
测试
测试自动化
频繁运行保值
为每一个Bug创建一个UT
集中火力对付边界条件
UT是昂贵的成本
为测试而设计
技巧
技巧

小步重构
同时只做一项重构
有TODO list
UT
20%


其他
80%
文档化
好样式,简单代码
有意义的名称
分解为原子函数
描述性类型
强调重要的代码
提供文件头
恰当的错误处理
有意义的注释
沟通
Reference
Thanks!

Contenu connexe

Tendances

Lamp优化实践
Lamp优化实践Lamp优化实践
Lamp优化实践zhliji2
 
高性能并发Web服务器实现核心内幕
高性能并发Web服务器实现核心内幕高性能并发Web服务器实现核心内幕
高性能并发Web服务器实现核心内幕ideawu
 
EventProxy introduction - JacksonTian
EventProxy introduction - JacksonTianEventProxy introduction - JacksonTian
EventProxy introduction - JacksonTianJackson Tian
 
Sun JDK 1.6内存管理 -调优篇
Sun JDK 1.6内存管理 -调优篇Sun JDK 1.6内存管理 -调优篇
Sun JDK 1.6内存管理 -调优篇bluedavy lin
 
mysql dbug
mysql dbugmysql dbug
mysql dbugTim Chou
 
Ria的强力后盾:rest+海量存储
Ria的强力后盾:rest+海量存储 Ria的强力后盾:rest+海量存储
Ria的强力后盾:rest+海量存储 zhen chen
 
高性能的Java代码编写及常见问题排查
高性能的Java代码编写及常见问题排查高性能的Java代码编写及常见问题排查
高性能的Java代码编写及常见问题排查bluedavy lin
 
Sun jdk 1.6内存管理 -使用篇
Sun jdk 1.6内存管理 -使用篇Sun jdk 1.6内存管理 -使用篇
Sun jdk 1.6内存管理 -使用篇bluedavy lin
 

Tendances (8)

Lamp优化实践
Lamp优化实践Lamp优化实践
Lamp优化实践
 
高性能并发Web服务器实现核心内幕
高性能并发Web服务器实现核心内幕高性能并发Web服务器实现核心内幕
高性能并发Web服务器实现核心内幕
 
EventProxy introduction - JacksonTian
EventProxy introduction - JacksonTianEventProxy introduction - JacksonTian
EventProxy introduction - JacksonTian
 
Sun JDK 1.6内存管理 -调优篇
Sun JDK 1.6内存管理 -调优篇Sun JDK 1.6内存管理 -调优篇
Sun JDK 1.6内存管理 -调优篇
 
mysql dbug
mysql dbugmysql dbug
mysql dbug
 
Ria的强力后盾:rest+海量存储
Ria的强力后盾:rest+海量存储 Ria的强力后盾:rest+海量存储
Ria的强力后盾:rest+海量存储
 
高性能的Java代码编写及常见问题排查
高性能的Java代码编写及常见问题排查高性能的Java代码编写及常见问题排查
高性能的Java代码编写及常见问题排查
 
Sun jdk 1.6内存管理 -使用篇
Sun jdk 1.6内存管理 -使用篇Sun jdk 1.6内存管理 -使用篇
Sun jdk 1.6内存管理 -使用篇
 

En vedette

The introduction of data visualization
The introduction of data visualizationThe introduction of data visualization
The introduction of data visualizationdreampuf
 
Communication with python_http_module
Communication with python_http_moduleCommunication with python_http_module
Communication with python_http_moduledreampuf
 
Python client api
Python client apiPython client api
Python client apidreampuf
 
Python magicmethods
Python magicmethodsPython magicmethods
Python magicmethodsdreampuf
 
Machine learning share No.1
Machine learning share No.1Machine learning share No.1
Machine learning share No.1dreampuf
 
Python profiling
Python profilingPython profiling
Python profilingdreampuf
 
A short introduction of D3js
A short introduction of D3jsA short introduction of D3js
A short introduction of D3jsdreampuf
 
The Outcome Economy
The Outcome EconomyThe Outcome Economy
The Outcome EconomyHelge Tennø
 

En vedette (8)

The introduction of data visualization
The introduction of data visualizationThe introduction of data visualization
The introduction of data visualization
 
Communication with python_http_module
Communication with python_http_moduleCommunication with python_http_module
Communication with python_http_module
 
Python client api
Python client apiPython client api
Python client api
 
Python magicmethods
Python magicmethodsPython magicmethods
Python magicmethods
 
Machine learning share No.1
Machine learning share No.1Machine learning share No.1
Machine learning share No.1
 
Python profiling
Python profilingPython profiling
Python profiling
 
A short introduction of D3js
A short introduction of D3jsA short introduction of D3js
A short introduction of D3js
 
The Outcome Economy
The Outcome EconomyThe Outcome Economy
The Outcome Economy
 

Similaire à Refactoring

OPOA in Action -- 使用MagixJS简化WebAPP开发
OPOA in Action -- 使用MagixJS简化WebAPP开发OPOA in Action -- 使用MagixJS简化WebAPP开发
OPOA in Action -- 使用MagixJS简化WebAPP开发leneli
 
MySQL新技术探索与实践
MySQL新技术探索与实践MySQL新技术探索与实践
MySQL新技术探索与实践Lixun Peng
 
互联网创业服务器运维工具集
互联网创业服务器运维工具集互联网创业服务器运维工具集
互联网创业服务器运维工具集zhen chen
 
Api Code Pack For Net Framework
Api Code Pack For Net FrameworkApi Code Pack For Net Framework
Api Code Pack For Net FrameworkChui-Wen Chiu
 
构建基于Lamp的网站架构
构建基于Lamp的网站架构构建基于Lamp的网站架构
构建基于Lamp的网站架构Cosey Lee
 
你的 JS 該減肥了!5個提升網頁載入速度的技巧 - Modern Web 2020
你的 JS 該減肥了!5個提升網頁載入速度的技巧 - Modern Web 2020你的 JS 該減肥了!5個提升網頁載入速度的技巧 - Modern Web 2020
你的 JS 該減肥了!5個提升網頁載入速度的技巧 - Modern Web 2020Shubo Chao
 
淘宝彩票移动项目开发实践
淘宝彩票移动项目开发实践淘宝彩票移动项目开发实践
淘宝彩票移动项目开发实践alvis-m
 
大话Php之性能
大话Php之性能大话Php之性能
大话Php之性能liqiang xu
 
Django敏捷开发 刘天斯
Django敏捷开发 刘天斯Django敏捷开发 刘天斯
Django敏捷开发 刘天斯liuts
 
从无阻塞并行脚本加载(Lab.js)到浏览器消息模型
从无阻塞并行脚本加载(Lab.js)到浏览器消息模型从无阻塞并行脚本加载(Lab.js)到浏览器消息模型
从无阻塞并行脚本加载(Lab.js)到浏览器消息模型Jackson Tian
 
开源应用日志收集系统
开源应用日志收集系统开源应用日志收集系统
开源应用日志收集系统klandor
 
Web性能测试指标参考v0.2
Web性能测试指标参考v0.2Web性能测试指标参考v0.2
Web性能测试指标参考v0.2beiyu95
 
Vulkan introduction
Vulkan introductionVulkan introduction
Vulkan introductionJiahan Su
 
淘宝商品库MySQL优化实践
淘宝商品库MySQL优化实践淘宝商品库MySQL优化实践
淘宝商品库MySQL优化实践Feng Yu
 
使用Nginx轻松实现开源负载均衡
使用Nginx轻松实现开源负载均衡使用Nginx轻松实现开源负载均衡
使用Nginx轻松实现开源负载均衡cachowu
 
Node js feat pegasus
Node js feat pegasusNode js feat pegasus
Node js feat pegasuscnfi
 
未来网络技术发展探梦 - 开篇
未来网络技术发展探梦 - 开篇未来网络技术发展探梦 - 开篇
未来网络技术发展探梦 - 开篇Yao-Wei Ou
 
Mybatis学习培训
Mybatis学习培训Mybatis学习培训
Mybatis学习培训flynofry
 
Mysql handlersocket
Mysql handlersocketMysql handlersocket
Mysql handlersocketpwesh
 

Similaire à Refactoring (20)

OPOA in Action -- 使用MagixJS简化WebAPP开发
OPOA in Action -- 使用MagixJS简化WebAPP开发OPOA in Action -- 使用MagixJS简化WebAPP开发
OPOA in Action -- 使用MagixJS简化WebAPP开发
 
MySQL新技术探索与实践
MySQL新技术探索与实践MySQL新技术探索与实践
MySQL新技术探索与实践
 
互联网创业服务器运维工具集
互联网创业服务器运维工具集互联网创业服务器运维工具集
互联网创业服务器运维工具集
 
Api Code Pack For Net Framework
Api Code Pack For Net FrameworkApi Code Pack For Net Framework
Api Code Pack For Net Framework
 
Micro service
Micro serviceMicro service
Micro service
 
构建基于Lamp的网站架构
构建基于Lamp的网站架构构建基于Lamp的网站架构
构建基于Lamp的网站架构
 
你的 JS 該減肥了!5個提升網頁載入速度的技巧 - Modern Web 2020
你的 JS 該減肥了!5個提升網頁載入速度的技巧 - Modern Web 2020你的 JS 該減肥了!5個提升網頁載入速度的技巧 - Modern Web 2020
你的 JS 該減肥了!5個提升網頁載入速度的技巧 - Modern Web 2020
 
淘宝彩票移动项目开发实践
淘宝彩票移动项目开发实践淘宝彩票移动项目开发实践
淘宝彩票移动项目开发实践
 
大话Php之性能
大话Php之性能大话Php之性能
大话Php之性能
 
Django敏捷开发 刘天斯
Django敏捷开发 刘天斯Django敏捷开发 刘天斯
Django敏捷开发 刘天斯
 
从无阻塞并行脚本加载(Lab.js)到浏览器消息模型
从无阻塞并行脚本加载(Lab.js)到浏览器消息模型从无阻塞并行脚本加载(Lab.js)到浏览器消息模型
从无阻塞并行脚本加载(Lab.js)到浏览器消息模型
 
开源应用日志收集系统
开源应用日志收集系统开源应用日志收集系统
开源应用日志收集系统
 
Web性能测试指标参考v0.2
Web性能测试指标参考v0.2Web性能测试指标参考v0.2
Web性能测试指标参考v0.2
 
Vulkan introduction
Vulkan introductionVulkan introduction
Vulkan introduction
 
淘宝商品库MySQL优化实践
淘宝商品库MySQL优化实践淘宝商品库MySQL优化实践
淘宝商品库MySQL优化实践
 
使用Nginx轻松实现开源负载均衡
使用Nginx轻松实现开源负载均衡使用Nginx轻松实现开源负载均衡
使用Nginx轻松实现开源负载均衡
 
Node js feat pegasus
Node js feat pegasusNode js feat pegasus
Node js feat pegasus
 
未来网络技术发展探梦 - 开篇
未来网络技术发展探梦 - 开篇未来网络技术发展探梦 - 开篇
未来网络技术发展探梦 - 开篇
 
Mybatis学习培训
Mybatis学习培训Mybatis学习培训
Mybatis学习培训
 
Mysql handlersocket
Mysql handlersocketMysql handlersocket
Mysql handlersocket
 

Refactoring