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 2008. You can download it from the Visual Basic developer center at http://msdn.microsoft.com/vbasic/; follow the links to Downloads, then Tools and Utilities.

Refactor! provides a range of additional refactoring support that complements the integrated support available for C# developers. However, this chapter's discussion is restricted to the built-in refactoring support provided within Visual Studio 2008 (for C# developers) and the corresponding action in Refactor! (for VB.NET developers).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.133.233