Archive

Archive for the ‘Refactor’ Category

Refactorings for anonymous types

September 27th, 2011 Comments off

Anonymous types are type declarations that are generated automatically by the compiler without having to explicitly declare it. They provide a convenient way to encapsulate several read-only properties into a single object that is not declared in the code. Anonymous types are supported by C# and Visual Basic programming languages starting from Visual Studio 2008.

Read more…

Refactorings for implicitly-typed local variables

September 27th, 2011 4 comments

Implicitly-typed local variables are variables declared without specifying the type explicitly. The type of such variables is being inferred from the expression that is used to initialize the variable at the time the code is compiled. Implicitly-typed variables are really useful for LINQ that creates anonymous types in queries, and for which you want to assign variables. However, implicitly-typed locals can be used with any variable declaration to enhance the readability, for example:

Refactor! Implicit variable sample

Read more…

Refactorings – Decompose Parameter

September 9th, 2011 Comments off

The Decompose Parameter refactoring splits a single parameter into one or more parameters, depending on the function of the original parameter. The refactoring analyzes how the parameter is used and which of its properties are accessed, after which it can replace a single parameter into several others of the appropriate type for each property being accessed through the original parameter.

Read more…

Refactorings that work with strings – Use StringBuilder

August 31st, 2011 Comments off

In addition to the refactorings that work with the concatenated strings and the String.Format call, there is another useful refactoring called Use StringBuilder. This refactoring replaces the string concatenation operations with corresponding methods of the StringBuilder class.

Read more…

String.Format-specific refactorings shipped in Refactor! Pro

August 31st, 2011 Comments off

Refactor! Pro provides several refactorings to create and organize the .NET String.Format call. The String.Format call is a static method that receives a string that specifies where the following arguments should be inserted, and how they should be formatted. You can specify the display options for each argument individually using the String.Format call.

Read more…

Refactorings and code providers for working with interface declarations

July 29th, 2011 Comments off

Refactor! Pro has many refactorings that are divided into several categories for clarity. One of the categories is Interfaces, where you can see the list of refactorings and code providers that are specific to interface declarations. The category is not as large as others at the moment, however, you might find these refactorings useful.

Read more…

Code Providers – Add to Interface

July 29th, 2011 Comments off

The Add to Interface code provider adds the active member declaration to the specified interface that is implemented by the current type. You can choose the target interface via the sub menu inside the Refactor! popup menu:

Read more…

Refactorings for C++: moving methods to source file and back to the header

July 29th, 2011 Comments off

There are two refactorings specific to the C++ language:

  • Move Method to Source File
  • Move Method to Header

Read more…