Archive for the ‘Refactorings’ Category

Refactoring ternary expressions into null-coalescing operations and vice versa

May 25th, 2011 Comments off

There are two interesting refactorings shipped in Refactor! Pro:

  • Compress to Null Coalescing Operation
  • Expand Null Coalescing Operation

The first one converts a ternary expression into an equivalent null coalescing operation. The second one is the opposite of the first one – it converts a null coalescing operation to an equivalent ternary expression. Both refactorings are available in CSharp only, because Visual Basic, for example, doesn’t have a null coalescing operator.

Read more…

Changing Signatures Refactorings – Convert to Tuple

May 19th, 2011 Comments off

The Convert to Tuple refactoring shipped in Refactor! Pro is similar to the Introduce Parameter Object refactoring, but it doesn’t create a new object – it uses the built-in .NET Framework 4.0 Tuple object.

Read more…

Refactorings for simplifying of .NET 4.0 parallel computing development

May 18th, 2011 Comments off

Many personal computers and workstations have two or four cores that enable multiple threads to be executed simultaneously. .Net Framework ver. 4.0 has been introduced a standardized and simplified way for creating robust, scalable and reliable multi-threaded applications. The parallel programming extension of .NET 4.0 allows the developer to create applications that exploit the power of multi-core and multi-processor computers. The flexible thread APIs of the extension are much simpler to use and more powerful than standard .NET threads.

Read more…

Refactorings – Introduce Alias

April 18th, 2011 Comments off

The Introduce Alias refactoring creates an identifier that serves as an alias for a namespace or type within the active source file. The alias directive can provide much neater and organized code. When several namespaces contain a matching class name, alias can also help to avoid a name conflict (ambiguous reference) without using the fully qualified type names, which improves overall code readability.

Read more…

Refactorings – Sort Namespace References

April 18th, 2011 Comments off

The Sort Namespace References refactoring is a stand-alone part of the Optimize Namespace References refactoring. In contrast to that refactoring, the Sort Namespace References refactoring doesn’t remove any references, and as the name says, it just sorts the ‘using’s (C#) or ‘Imports’ (VB) statements in the active source file.

The following sorting methods are available:

  • Alphabetically
  • By Length

Read more…

Refactorings – Optimize Namespace References

April 15th, 2011 Comments off

The Optimize Namespace References refactoring removes namespace references (usings (in C#) or Imports (in VB)) that are not needed in the active source file, either because they were added automatically and not used, or because the code that did require them has been removed or relocated. Also, it can automatically sort used references after refactoring is performed: alphabetically, by length or not sort. An additional sorting option is to move all System references at the top of the list (file). The refactoring improves code readability.

Read more…

Refactorings – Flatten Conditional

March 22nd, 2011 Comments off

This is one of the most powerful refactorings for conditionals – it helps you to simplify conditional statements by unindenting all or a portion of the conditional statement which improves the clarity of the code. This refactoring includes several different refactorings mentioned in Martin Fowler‘s book, and a few others. These refactorings are applied, depending on the conditional blocks you have inside the source code. Here they are:

Read more…

Refactorings – Inline Method

February 17th, 2011 Comments off

The Inline Method refactoring lets you move the method’s body into the body of its callers and remove the method declaration, if needed. Inline Method is helpful when you have a group of methods that seem badly factored. You can inline them all into one big method, and then re-extract the methods.

Another reason to use Inline Method is that sometimes you do come across a method in which the body is as clear as the name. Or, you refactor the body of the code into something that is just as clear as the name. When this happens, you should then get rid of the method.

Read more…