Archive

Archive for the ‘Refactorings’ Category

Adding and removing block delimiters in C#/C++ and JavaScript

March 12th, 2012 3 comments

In C#, C++ and JavaScript languages, curly braces are used as block delimiters. A block allows multiple statements to be written inside. If a block contains a single statement, block delimiters, in most cases, are optional. For example, a single statement inside a loop does not require block delimiters:

CodeRush Optional block delimiters sample

Read more…

Refactorings for changing members accessibility and scope visibility

February 13th, 2012 Comments off

There are a couple of visibility-changing refactorings shipped in DevExpress Refactor! Pro.

Reduce Visibility

This refactoring allows you to quickly reduce the visibility of a member to match the highest calling visibility, in other words, to restrict the visibility as much as possible.

Read more…

Refactorings – Reduce Visibility

February 13th, 2012 Comments off

Each member of a type declaration has an associated visibility (accessibility) modifier, which controls the access to this member for other members. The Reduce Visibility refactoring shipped in Refactor! Pro allows you to quickly reduce the visibility of a member to match the highest calling visibility, in other words, to restrict the visibility as much as possible.

Read more…

Refactorings for variable scope widening (Widen Scope)

January 24th, 2012 Comments off

The scope of a variable declaration determines its visibility to the rest of a program. Scopes can be member-level, class-level and nested, where an inner scope may re-declare the meaning of a variable from an outer scope.

When declared inside a member, the scope of the variable is the entire member after the variable declaration, including all nested code blocks. This means that the variable is available to use within the member but when control passes to another member, the variable is unavailable.

Read more…

Refactoring Visual Basic With statements

January 17th, 2012 Comments off

The With statement (in Visual Basic) is used to execute a series of statements of the particular object without requalifying the name of the object. In other words, we can use the With statement to reduce the number of times we needed to manually type the full path to the target object. For example, this function inverts the background color of the active control of the active form in the current Windows application:

Refactoring With Statement sample code

Read more…

Refactorings strings in Visual Studio using CodeRush

November 30th, 2011 Comments off

The String data type of .NET Framework is one of the most often used types when developing software. There are a number of basic operators available for use with strings, such as concatenation and equality comparison. Also the data type is based on a class that includes many powerful methods for string manipulation. Let’s take a brief look at what refactorings shipped in DevExpress Refactor! Pro help us deal with the String data type. You can follow each link, to learn more about a specific refactoring.

Read more…

Refactorings that work with strings – Use String.Compare

November 30th, 2011 Comments off

The Use String.Compare refactoring shipped in DevExpress Refactor! Pro allows you to convert a usual string equality comparison (==) into a more flexible Compare call on the System.String class. Consider the following code:

Use String.Compare refactoring sample code

Read more…

Refactorings that work with strings – Use Environment.NewLine

November 25th, 2011 Comments off

The Use Environment.NewLine refactoring is one of the simplest refactoring shipped in DevExpress Refactor! Pro which improves code portability. This refactoring replaces the “\r\n” string with the value of the Environment.NewLine property reference. The Environment.NewLine is a static string property from the System namespace that is tied to the current executing environment (platform). It returns a valid “line feed/carriage return” string that corresponds to the current operating system, for example: “\r\n” for Windows platforms, or a string containing just a line feed (“\n“) for Unix platforms.

Read more…