随笔分类 - Refactoring
Improving the Design of Existing Code-------Martin Fowler
All rights belongs to Martin Fowler.
Click this link for detail:http://www.refactoring.com/catalog/
摘要:You want to replace an algorithm with one that is clearer. Replace the body of the method with the new algorithm.
阅读全文
摘要:You have a long method that uses local variables in such a way that you cannot apply extract method. Turn the method into its own object so that all the local variables become fields that object. You ...
阅读全文
摘要:The code assigns to a parameter. Use a temporary variable instead.
阅读全文
摘要:You have a temporary variable assigned to more than once, but is not a loop variable nor a collecting temporary variable.Make a separate temporary variable for each assignment.
阅读全文
摘要:You have a complicated expression. Put the result of the expression, or parts of the expression, in a temporary variable with a name that explains the purpose.
阅读全文
摘要:You are using a temporary variable to hold the result of an expression. Extract the expression into a method. Replace all references to the temp with the expression. The new method can then be used in...
阅读全文
摘要:You have a temp that is assigned to once with a simple expression, and the temp is getting in the way of other refactoring.Sample: BeforeCode highlighting produced by Actipro CodeHighlighter (freewar...
阅读全文
摘要:A method's body is just as clear as its name. Put the method’s body into the body of its callers and remove the method.Sample: BeforeRefactorCode highlighting produced by Actipro CodeHighlighter (fr...
阅读全文
摘要:You have a code fragment that can be grouped together.Turn the fragment into a method whose name explains the purpose of the method. Why: First, it increases the chances that other methods can use a ...
阅读全文

浙公网安备 33010602011771号