Refactoring improving the design of existing code (1)
来源:互联网 发布:苹果手机数据流量开关 编辑:程序博客网 时间:2024/06/05 11:23
When you find you have to add a feature to a program, and the program’s code is not structured in a convenient way to add the feature, first refactor the program to make it easy to add the feature, then add the feature.
The First Step in Refactoring
Whenerver I do refactoring , the first step is always the same. I need to build a solid set of tests for that section of code.
Before you start refactoring , check that you have a solid suite of tests. These tests must be self-checking.
Extract Method
For adding HTML statement method. I am looking to decompose the method into smaller pieces.
When I extract a method , as in any refactoring, I need to know what can go wrong. So I’ve written down the safe steps in the catalog. Pay attention to switch statement or other logical block.
First I need to look in the fragment for any variables that are local in scope to the method we are looking at, the local variables and parameters. Which variables are modified and others not. Any non-modified variable I can pass in as a parameter. Modified variables need more care.
Method is on the wrong object. In most cases a method should be on the object whose data it uses.
Extracting method for header, footer, and detail line are one route I could take. Form Template Method.
- Refactoring: Improving the Design of Existing Code
- Refactoring improving the design of existing code (1)
- 代码的规范化:《Refactoring: Improving the Design of Existing Code》
- 读重构 (Refactoring:Improving the Design of Existing Code)
- 《Refactoring-Improving the Design of Existing Code》读书笔记
- Refactoring-Improving the Design of Existing Code——学习笔记(1)
- 重温:Martin Fowler的Refactoring Improving the Design of Existing code
- Refactoring-Improving the Design of Existing Code——学习笔记(2)
- Refactoring-Improving the Design of Existing Code——学习笔记(3)
- Refactoring-Improving the Design of Existing Code——学习笔记(4)
- Refactoring-Improving the Design of Existing Code——学习笔记(5)
- Refactoring-Improving the Design of Existing Code——学习笔记(6)
- Refactoring-Improving the Design of Existing Code——学习笔记(7)
- Refactoring-Improving the Design of Existing Code——学习笔记(8)
- Refactoring HTML: Improving the Design of Existing Web Applications
- {Refractoring - Improving the design of existing code} - 1999
- Refecing Improving the Design of Existing Code reading comments(一)
- Refecing Improving the Design of Existing Code reading comments(二)
- 无法串行访问事务错误:ORA-08177: can't serialize access for this transaction
- lost有感
- java设计模式学习系列之一:单例模式(Singleton)
- FBreader
- 初识网络游戏防作弊
- Refactoring improving the design of existing code (1)
- swf 头标签tag
- Qt中使用QProcess备份和恢复Mysql数据库
- C++读书笔记——typeid操作符(2009-8-1 9:22:00)
- boj1816
- vim常用命令
- 1.环境变量
- 5000次掷骰子实验代码(VB)
- H.264中MV预测过程详解