代码重构
文章平均质量分 77
小文_panda
无
展开
-
Refactoring Day 9 : Extract Interface
Today we look at an often overlooked refactoring. Extract Interface. When you notice more than one class using a similar subset of methods on a class, it is useful to break the dependency and introd转载 2014-11-18 15:35:41 · 412 阅读 · 0 评论 -
重新组织函数的九种方法
转载自:http://blog.csdn.net/hguisu/article/details/7598066函数过长或者逻辑太混乱,重新组织和整理函数的代码,使之更合理进行封装。1. Extract Method 提炼函数提炼函数:(由复杂的函数提炼出独立的函数或者说大函数分解成由小函数组成)你有一段代码可以被组织在一起并独立出来。将这段代码放转载 2015-02-11 09:37:14 · 508 阅读 · 0 评论 -
简化条件表达式
简化条件表达式http://blog.csdn.net/hguisu/article/details/76137661.Decompose Conditional 分解条件表达式你有一个复杂的条件语句。从if、then、else三个段落中分别提炼出独立函数。程序之中,复杂的条件逻辑是最常导致复杂度上升的地点之一。你必须编写代码来检查不转载 2015-02-06 14:00:18 · 601 阅读 · 0 评论 -
Refactoring Day 6 : Push Down Field
Opposite of the Pull Up Field refactoring is push down field. Again, this is a pretty straight forward refactoring without much description needed 1: public abstract class Task 2: { 3: prot转载 2014-11-18 15:12:15 · 382 阅读 · 0 评论 -
Refactoring Day 5 : Pull Up Field
Today we look at a refactoring that is similar to the Pull Up method. Instead of a method, it is obviously done with a field instead! 1: public abstract class Account 2: { 3: } 4: 5:转载 2014-11-18 15:09:20 · 458 阅读 · 0 评论 -
Refactoring Day 3 : Pull Up Method
The Pull Up Method refactoring is the process of taking a method and “Pulling” it up in the inheritance chain. This is used when a method needs to be used by multiple implementers. 1: public abst转载 2014-11-18 14:50:40 · 978 阅读 · 0 评论 -
Refactoring Day 2 : Move Method
The refactoring today is pretty straightforward, although often overlooked and ignored as being a worthwhile refactoring. Move method does exactly what it sounds like, move a method to a better lo转载 2014-11-18 14:46:52 · 466 阅读 · 0 评论 -
Refactoring Day 8 : Replace Inheritance with Delegation
All too often inheritance is used in the wrong scenarios. Inheritance should only be used in logical circumstances but it is often used for convenience purposes. I’ve seen this many times and it lea转载 2014-11-18 15:20:33 · 385 阅读 · 0 评论 -
Refactoring Day 4 : Push Down Method
Yesterday we looked at the pull up refactoring to move a method to a base class so mutiple derived classes can use a method. Today we look at the opposite. Here is the code before the refactoring:转载 2014-11-18 15:03:32 · 381 阅读 · 0 评论 -
Refactoring Day 1 封装集合
Refactoring Day 1 : Encapsulate Collection In certain scenarios it is beneficial to not expose a full collection to consumers of a class. Some of these circumstances is when there is additional转载 2014-11-18 14:40:53 · 415 阅读 · 0 评论 -
Refactoring Day 7 : Rename (method, class, parameter)
This refactoring I use most often and is one of the most useful refactoring. All too often we do not name methods/classes/parameters properly that leads to a misunderstanding as to what the method转载 2014-11-18 15:14:59 · 462 阅读 · 0 评论 -
简化函数调用
非常感谢这位同学的文章。http://blog.csdn.net/hguisu/article/details/7631886重构的确是编程人员的修养啊1. Rename Method 函数改名函数的名称未能揭示函数的用途。修改函数名称。大力提倡的一种编程风格是:将复杂的处理分解成小函数。但是,如果做得不好,这会使你费尽周折却弄不清楚这些小函数转载 2015-02-10 18:30:50 · 476 阅读 · 0 评论