Archive

Posts Tagged ‘Fields’

Promoting locals and constant value expressions into parameters

July 31st, 2012 Comments off

There are times when you realize that a local variable or a field reference within a method would be more useful if it was a parameter. Having a new parameter on a method will increase its flexibility for consumers. To convert the local variable, you should remove its declaration from the body of the method, add it as a parameter and replace all occurrences of a local to a new parameter. The same steps must be performed in the case of field references. Furthermore, all method references in the entire solution should be updated to pass a new value as an argument to a method with a new signature.

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 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…

Declaring fields using CodeRush consume-first declaration features

December 16th, 2011 Comments off

Unlike the local variable declarations, fields are simply variables that are declared directly within the code block of a class or a structure. Fields are declared in the type block by specifying the access level of the field, the type of the field and the name of the field. A field may also include a readonly modifier. This type of field can only have its value set directly in its declaration or from within a constructor of its containing class.

Read more…