Skip to navigation

PCPro-Computing in the Real World Printed from www.pcpro.co.uk

Register to receive our regular email newsletter at http://www.pcpro.co.uk/registration.

The newsletter contains links to our latest PC news, product reviews, features and how-to guides, plus special offers and competitions.

Real World Computing

Apps versus solutions

Posted on 4 Mar 2009 at 11:04

Simon Jones asserts that "solution" isn't a dirty word, and finds some powerful code-optimisation tools.

Another very handy tool I use every day when programming is CodeRush from Developer Express. It greatly speeds up writing and editing Visual Studio code in VB.NET and C#, by adding extra functions such as automatically completing brackets and identifiers, and expanding short templates into complicated code snippets. These templates can be as simple as expanding "f" to "false", "l" to "else", or "tf" into "try ... catch ... finally ... end try". Each template is context sensitive so, for instance, if you have a collection variable stored on the Clipboard, typing "fe" will generate a complete "For Each" loop that will iterate through the members of that collection, giving a sensible name to the member variable and leaving the cursor at the right place for you to continue typing the rest of the code. If you want to surround a block of code with a call to show the wait cursor, just select the relevant code and press "W". If you want a "#Region ... #End Region" directive around a number of procedures or declarations, that too is just one key-press away. It's also one key-press to swap rows and columns, invert the condition of an If statement, or reverse the direction of a "For... Next" loop.

CodeRush also enhances the rendering of the code in Visual Studio's editor, so that subs and functions show icons indicating their scope and measures of their complexity, letting you know when you ought to simplify a complex procedure by breaking it into smaller chunks. You also get vertical lines drawn at each indent level, so your eye can easily scan up or down to find the corresponding end to a loop or conditional. CodeRush is very powerful and configurable, as all its templates can be customised to your own naming conventions, or other requirements, and you can define your own templates if a commonly used action isn't sufficiently automated for your liking. It also comes with a free copy of Refactor! Pro, one of the most extensive refactoring tools available.

Refactoring is the process of changing the way some code is written without changing the actual effect it has when executed. This is usually done to simplify the code and make it run faster, easier to understand and easier to maintain. A simple example might be to change the statement:

If booSaved Then

booDirty = False

Else

booDirty = True

End If

into the more elegant, efficient and obvious:

booDirty = Not booSaved

This single line has exactly the same outcome as that five-line If ... Then ... Else construct, but runs quicker and is easier to maintain. Refactor! Pro knows how to perform hundreds of different refactorings of this sort, such as extracting a range of code lines into a separate method, changing For...Each loops into For...Next or vice versa, replacing multiple occurrences of the same expression with a variable, promoting local variables to parameters, and replacing repetitive string concatenation with the more efficient StringBuilder class.

Used together, CodeRush and Refactor! Pro speed up the writing and maintenance of Visual Studio code so much that I couldn't do without them. The DevExpress website (www.devexpress.com) has lots of good training videos to help you make the most of CodeRush and Refactor! Pro, which complement the help text and guidance windows built into the products. CodeRush with Refactor! Pro costs $250 and comes with a year's free updates, while Refactor! Pro on its own costs $99. New versions appear three or four times a year, each containing bug fixes and enhancements, and providing three or four good reasons to keep on subscribing.

1 2 3 4
Be the first to comment this article

You need to Login or Register to comment.

(optional)

advertisement

Latest Real World Computing
Latest Blog Posts Subscribe to our RSS Feeds
Latest News Stories Subscribe to our RSS Feeds
Latest Reviews Subscribe to our RSS Feeds

advertisement

Sponsored Links
 
SEARCH
SIGN UP

Your email:

Your password:

remember me

advertisement


Hitwise Top 10 Website 2008