Archive

Archive for the ‘Refactor’ Category

Refactorings preview hinting

September 24th, 2010 5 comments

Almost all refactorings have a preview hint which allows you to see the resulting code before a particular refactoring is performed. This is very useful, because it is a great help to understand what will happen in the code once an action is taken. Moving among available refactorings in the Refactor! popup menu or a SmartTag popup menu will be reflected in the preview for each one. Here are previews of some possible refactorings you can perform using the Refactor! popup menu:

Read more…

How to perform a code refactoring using IDE tools

September 7th, 2010 Comments off

There are several methods which allow you to perform a particular refactoring. Multiple methods are provided to ensure that you feel comfortable inside the Visual Studio IDE. These approaches are available:

Read more…

What is refactoring? Benefits of a code refactoring

September 7th, 2010 Comments off

Refactoring is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior. Its heart is a series of small behavior preserving transformations. Each transformation (called a ‘refactoring’) does little, but a sequence of transformations can produce a significant restructuring. Since each refactoring is small, it’s less likely to go wrong. The system is also kept fully working after each small refactoring, reducing the chances that a system can get seriously broken during the restructuring.”

Martin Fowler, www.refactoring.com

Read more…

Refactorings – Introduce Parameter Object

August 13th, 2010 Comments off

The Introduce Parameter Object refactoring consolidates selected parameters into single object. If you frequently need to pass similar sets of values to methods that tend to be passed together, it might be useful to encapsulate these values into an object that carries all of this data. It is worthwhile to turn these parameters into objects just to group the data together. As the result, calling statements will become more compact and you will be able to add data processing logic to the newly declared object. This refactoring is also useful because it reduces the size of the parameter lists, and long parameter lists are hard to read and understand.

Read more…

Refactorings – Remove Parameter

August 13th, 2010 Comments off

Also known as Remove Unused Parameter. This refactoring removes an unused parameter from a method declaration, and updates all calls accordingly. It is very useful when a parameter is no longer used by the method body. A spurious parameter doesn’t cause any problems, and you probably might need it again later. But most of the time this is the wrong choice, because a parameter indicates information that is needed. In this case, a caller has to worry about what values to pass for a fictitious, unused parameter. By not removing the parameter you are making further work for everyone who uses the method.

Read more…

Refactorings – Add Parameter

August 13th, 2010 Comments off

The refactoring adds a new parameter to a method declaration and updates all calls accordingly. This refactoring is useful when you need to quickly add a new parameter to an existing method because it needs more information from its caller that wasn’t passed in before. Bear in mind that if there are alternatives available against doing this refactoring, it is preferred to use those alternatives instead, because they don’t lead to increasing the length of parameters lists. Long parameter lists are hard to remember and often involve data clumps.

Read more…

Refactorings – Extract Method

August 13th, 2010 Comments off

The Extract Method refactoring creates a new method from the selected code block. The selection is replaced with appropriate calling code to invoke the newly-declared method. The Extract Method is great when you need to turn a big, complex method into smaller, simpler ones. Small methods are much easier to maintain, and encourage code reuse, and also have the following advantages:

  • It increases the chance that other methods can use a simple method when the method is finely organized and well-formed.
  • It allows the higher-level methods to read more like a series of comments, which improves the code readability. Simple methods with good names comment themselves, and improve overall code clarity. Overriding also is easier when the methods are finely grained.

Read more…

Differences between paid (Pro) and free Refactor! versions

July 13th, 2010 3 comments

All Refactor! products such as Refactor! Pro, Refactor! for C++, Refactor! for ASP.NET differ mostly by the refactorings set. CodeRush Xpress contains refactorings too, so we’ll compare refactorings with this product as well. Note that Refactor! Pro contains an additional Metrics tool window feature.

Read more…