Refactoring is the process of restructing the code, without changing its behavior.
The process will improve the design of existing code.
There are some patterns, look in look in Martin Fowler Refactoring site http://www.refactoring.com/catalog/index.html for a comprehensive list.
The most common patterns are:
Extract Method: Group related pieces of code into a method.
Rename: Rename any symbol (namespace, type, method, class, package,field,...) to an understanding name
Move Type: Nove types between namespaces/packages
Extract type to a new file: Move code, implementing it in a new file
Change Signature: Add/remove/reorder/rename/change parameters of a method
Introduce Variable: Create a local variable to make code more readable
Inline variable: Inverse of introduce variable refactoring. Replace variable with its initializer.
Convert method to property
Convert property to method
Unit tests should also be refactored, since they are implemented as code.
Tools
There are some Refactoring tools available, look at http://www.refactoring.com/tools.html for a complete list.
c# free tools
http://opnieuw.com/
http://softwarestudio.smartcoding.org
Exercises:
http://www.xp123.com/rwb/
References:
http://www.refactoring.com/
http://www.xp123.com/
No comments:
Post a Comment