Archive

Archive for the ‘CodeRush’ Category

Duplicate Detection and Consolidation overview

December 20th, 2011 Comments off

This is a blog series overview of the Duplicate Detection and Consolidation (DDC) feature shipped in DevExpress CodeRush Pro productivity tool for the Visual Studio IDE.

Background

Duplicate code, or sometimes referred to as a clone, is a program source code fragment that is very similar to another code fragment. A code clone may occur more than twice, either within a single program or across different programs owned or maintained by the same group of developers. Code duplication is considered an expensive practice that should be avoided because it complicates the maintenance and evolution of the software.

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…

Declaring locals using CodeRush consume-first declaration features

December 16th, 2011 Comments off

Local variable declarations are the most often used types of declarations in code. A local variable is a type of variable declared by local variable declaration inside a block the variable is intended to be local to. The local variable declaration explicitly defines the type of the variable that has been declared along with the identifier that names the variable. You can also declare implicitly typed local variables, whose type is inferred by the compiler from the expression.

Read more…

Code Issues for Switch (Select) and Case statements

December 14th, 2011 Comments off

A switch statement executes logic, dependent on the value of a given expression (parameter). The types of values a switch statement operates on can be boolean, enum, integral types, and strings. Each switch statement can contain any number of case statements, but no two case constants within the same switch statement can have the same value. Each case statement defines a value to compare against the original expression. You may also include a default label following all other case statements. If none of the other choices match, then the default choice is taken and its statements are executed. If there is no default label, control is transferred outside the switch.

Read more…

Declaring enumeration types and its elements in CodeRush

December 14th, 2011 Comments off

An enumeration type is a special set of related constants, each with an integer value. Enumerations are useful for defining states and sequences, particularly when there is a natural progression through those states. Each constant in the enumeration list can be compared and formatted using either its name or value. For example, assume that you have to define a variable whose value will represent a day of the week. There are only seven meaningful values which that variable will ever store. To define those values, you can use an enumeration type.

Read more…

Code Issues – Member is not implemented

October 31st, 2011 Comments off

Cause:

The Member is not implemented code issue of the warning type is shown for the members that do not provide an implementation. Not providing an implementation may be a sign of incomplete code.

The code issue is shown for non-interface, non-abstract, non-virtual, non-extern members – both methods and properties. It is not shown for constructors and destructors of a class.

Read more…

Converting methods to functions or procedures

October 31st, 2011 Comments off

The simplest type of method is one that performs a task without requiring any parameters and without returning any information – let’s call them procedures (or void methods). Methods that use some type as the return value – are functions.

Sometimes, when we declare a method with a return value, we may realize that we don’t actually need this return value, and instead, need a simple void method that does not return anything. On the other hand, we marked a method as void, but may require it to be a function, returning a value.

Read more…

Code Issues for anonymous methods and lambda expressions

October 31st, 2011 Comments off

We already reviewed the refactorings for anonymous methods and lambda expressions and know how to deal with these language structures. Now its time to review what Code Issues for anonymous methods and lambda expressions CodeRush Pro provides.

Read more…