Duplicated Code
来源:互联网 发布:淘宝手机主板可靠吗 编辑:程序博客网 时间:2024/04/30 12:15
If you see the same code structure in more than one place, you can be sure that your program will be better if you find a way to unify them.
1. The simplest duplicated code problem is when you have the same expression in two methods of the same class.
Extract Method
2. Another common duplicated code problem is when you have the same expression in two sibling subclasses.
Extract Method in both classes then Pull UP Field.
If the code is similar but not the same, you need to use
Extract Method to separate the similar bits from the different bits. You may then find you can use Form Template Method. If the methods do the same thing with a different algorithm, you can choose the clearer of the two algorithms and use Substitute Algorithm.
3. If you have duplicated code in two unrelated classes, consider using
Extract Class in one class and then use the new component in the other. Another possibility is that the method really belongs only in one of the classes and should be invoked by the other class or that the method belongs in a third class that should be referred to by both of the original classess.
- Duplicated Code
- 3.1duplicated code
- [重构]Duplicated code
- idea find duplicated code 关闭idea的 duplicated code 提示
- found duplicated code in this file
- 代码的坏味道之一 :Duplicated Code(重复的代码)
- 重构---需要重构的地方-----Duplicated Code(重复代码)
- 遇到 definition duplicated 怎麼辦
- 去除重复行duplicated
- How the duplicated edis occur ?
- sgu295:Identifier Duplicated!(组合数学)
- JQuery警告:Duplicated jQuery selector
- (前端)警告:Duplicated jQuery selector
- Cakephp: findAll query return duplicated records
- remove duplicated value in an array
- a sample for deleting duplicated records
- remove duplicated chars in a string
- Hspice仿真error:duplicated subckt definition 'nch_mac'
- oracle存储过程调用java类
- C++ Primer ------ 卷首语
- UDT协议-基于UDP的可靠数据传输协议
- MFC对话框中控件 添加右键响应
- 学习jQuery必须知道常用的几种方法
- Duplicated Code
- Compute PI in parallel
- 我在飘
- SharePoint 2010系列--SharePoint 2010的数据库
- ArcGIS API for Android 案例教程 7
- asp.net 取路径问题
- ArcGIS API for Android 案例教程 8
- 无刷新图片上传
- SBT 平衡二叉树模板