Chapter 17. Code Snippets and Refactoring

Code snippets are small chunks of code that can be inserted into an application's code base and then customized to meet the application's specific requirements. They do not generate full-blown applications or whole form definitions, unlike project and item templates. Instead, code snippets shortcut the programming task by automating frequently used code structures or obscure program code blocks that are not easy to remember. In the first part of this chapter you'll see how code snippets are a powerful tool that can improve coding efficiency enormously, particularly for programmers who perform repetitive tasks with similar behaviors.

One technique that continues to receive a lot of attention is refactoring, the process of reworking code to improve it without changing its functionality. This might entail simplifying a method, extracting a commonly used code pattern, or even optimizing a section of code to make it more efficient. The second part of this chapter reviews the refactoring support offered by Visual Studio 2008.

Unfortunately, because of the massive list of functionality that the VB.NET team tried to squeeze into Visual Studio 2005, support for a wide range of refactoring actions just didn't make the cut. Luckily for VB.NET developers, Microsoft came to an arrangement with Developer Express to license the VB version of its Refactor! product. This arrangement continues, giving VB.NET developers access to Refactor! for Visual Studio ...

Get Professional Visual Studio® 2008 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.