Here's a way to recode objects in many ways without losing your place.
Refactoring is the process of rearranging code in a disciplined way.
The goal of refactoring is to go from messy code to clean code, with all
of the advantages in understandability that that implies (for more information,
see Martin Fowler's excellent book on the subject or his Web site http://www.refactoring.com/).
Of course, where there's a technique there's a tool. C# Refactory is
a tool designed to help you refactor C# code in the .NET interface by
simply selecting menu choices and filling in simple dialogs. In its first
incarnation, C# Refactory supports these refactorings:
- Extract Method
- Extract Superclass
- Extract Interface
- Copy Class
- Rename Parameter
- Raname Local Variable
- Rename Member
- Rename Type
Take "Extract Interface," for example. After a development session you
might realize that you've got some functionality that needs to be generalized
and then reimplemented in several different ways. With the Extract Interface
refactoring, you just supply a name for the new interface and specify
which methods of the existing class should come from the interface. C#
Refactory builds the interface definition and modifies the class to implement
the interface, without any manual intervention.
In addition, C# Refactory supplies a set of metrics (lines of code, cyclomatic
complexity, lines of comments, and so on) that can be calculated on any
level from solution on down. If your development process is at all driven
by this sort of number, you'll find this useful.
I was impressed at how easy to use this product was after installation.
Though the initial catalog of refactorings is fairly small, they seem
to have thought hard about what would be useful. And they're improving
fast; indeed, while I was editing this review, a new version with one
more refactoring was available for download to my computer. If you're
working on a large object-oriented C# project, you'll find a home for
this in your tool kit.
About the Author
Mike Gunderloy, MCSE, MCSD, MCDBA, is a former MCP columnist and the author of numerous development books.