Last month's article gave an overview of Visual Studio .NET 2005's new team environment capabilities, SQL Server 2005, and Microsoft's remarkable one-year pricing policy. This month, I cover some of the enhancements that Microsoft has made to the Visual Studio 2005 Interactive Development Environment (IDE). Many of the new capabilities of the Visual Studio IDE make it easier to produce good code and harder to make mistakes.
The Windows Developer Community
With Visual Studio .NET 2005, Microsoft has made a greater effort to establish a sense of "community" among Windows developers. Not only the coders that are part of a project team, but also the single programmers, working alone, are made to feel a part of a group of like-minded developers.
When you start Visual Studio 2005, you are greeted with an opening screen, called the Start Page, that is essentially an embedded HTML browser. This browser is pointed to a news source at the Microsoft Development Network (MSDN), where announcements of features, training, and tools are made. Therefore, each time we developers open the IDE, we all see the same news and announcements.
To further promote the sense of community, Microsoft has a new IDE menu, called Community, dedicated to such collaborative efforts as Ask a Question, Send Feedback (to answer a question), and Check Question Status. Another option, Developer Center, points the embedded browser to the MSDN main Web site.
The Visual Studio Codezone
While not entirely new, perhaps the most valuable Community resource is the Codezone, which is a collection of links to most of the major independent Windows development experts, individual contributors, user groups, community sites, and speakers, including C# Corner, CodeGuru, DevX, Code Project, and SQL Team. Hundreds of articles, code examples, tips, and practical applications are cataloged and available for research. Code examples covering practically every likely need are essentially available online, all the time. There is little need to carry any sort of hardcopy reference anymore.
Finally, VS 2005 gives you a hand in sorting through all this newfound community information with the new Community Search option. Community Search lets you look through the resources of the Codezone for templates, code snippets, code samples, starter kits, and custom controls. For example, a Codezone search for the term "exit()" and limited to the C# language yields about 20 articles on good coding practices, misuse examples, tricks, and workarounds. Further, all of the information resources may be searched at the same time. That means you can examine search results from the Codezone community, local help, MSDN online, and the Question and Answer knowledge base from a single consolidated screen, while making a single search request. You may also apply filters to restrict your search to a subset of VS languages (VB and C#, for example), to a specific technology (like MFC or .NET), or to a specific type of information (articles, code samples, etc.).
Testing Tools for Agile Software Engineers
In recent years, the software engineering methods have taken a turn away from the more established paradigms, like the Waterfall and Spiral methods, toward a more agile approach like Extreme Programming (called "XP" but not to be confused with the Windows operating system) or another similar method called Scrum. Engineering methods like XP and Scrum are less reliant on heavyweight documentation and milestones; they draw instead on "user stories" and very short iterative development cycles. Testing, therefore, is crucial to the success of an agile engineering process. In fact, some agile engineering enterprises construct the test for a given chunk of software before the given chunk is even designed. Into this trend springs Microsoft.
Visual Studio 2005 has many new features to bring testing as a concept into its own. Tests may be established in advance and independently of the components they're going to test. For example, suppose you are creating a Web application and you want to know what will happen when hundreds of requests come in to your server at the same time. You can create a Web test script to perform a set of recorded Web requests and then a load test to encapsulate the script and execute it as hundreds of virtual users, all making requests simultaneously. Results of the test may be captured and analyzed to determine where improvements to the code may be realized.
Unit testing, where the methods of a component are exercised, can be invoked with automatically generated initial code. Multiple unit tests may then be bundled into a battery of tests and invoked together. The results of the testing can be logged and reviewed, and the effectiveness of the software measured.
Refactoring
Source code refactoring is the practice of changing the internal arrangement of a program while leaving the external behavior unaltered. It's something programmers do all the time. For example, when you find that you have the same few lines of code duplicated several times around your program, you might decide to create a subroutine or procedure to contain the common code and then call the routine from those various places. The code becomes cleaner and easier to maintain.
Visual Studio 2005 now has tools to help with many refactoring tasks. For instance, suppose you want to rename a variable that is used in a function. Yes, I know "find and replace" has been available all along, but the VS 2005 refactoring tools are more intelligent than that. Let's say the goal is to rename the variable sWork to sWork1, but this cannot be done properly with "find and Replace" because there are other variables that begin with sWork (sWork2, sWork3, etc.), and these field names will be changed, too. Well, we're in luck because the Visual Studio refactoring tool knows the difference.
In Figure 1, the refactoring dialog for "rename" is shown. In the top panel, all of the references to the variable sWork are displayed. Note that references to sWork2, sWork3, etc. are not included and will not be altered when the changes are applied.
Figure 1: The refactoring dialog for "rename" displays all of the references to the variable sWork.
Other new refactoring tools help you with these tasks:
- Encapsulate a class variable into a class property
- Extract some code from one area of a program and turn the code into a method or an interface (something that would have been handy in the above example of creating a subroutine from duplicate code)
- Promote a local variable to a method parameter
- Remove parameters
- Reorder parameters
In most of these cases, Visual Studio will perform some error checking as you go to make sure your refactoring changes will compile and run as expected. For example, when promoting a variable to a method parameter, VS checks to see that the variable gets an initial value before it's referenced. Further, renaming a control, like a button or text box, after a great deal of code has been written that references that code, will invoke a more intelligent search for references to the control and make most of the changes that would be required.
Some Nice Touches
Naturally, with over 400 enhancements to the IDE, different features will appeal to different programmers. These are some of the improvements that I find most helpful:
- The "Surround with..." feature allows you to select some code and then surround it with any one of several types of expansions (like #region...#endregion, do...while, or if {}). This tool can be very helpful in keeping nested levels in their proper places.
- New security features, particularly for developing ASP.NET Web applications, allow you to, for example, write a Web application that requires only partial permissions because the new Permissions Calculator scans your code and determines which specific permissions are required.
- Error conditions within the IDE are easier to detect, even without benefit of a compile.
- The Intellisense displays of methods and properties are more informative. As object references are displayed, a new tool tip shows the usage for each property, method, or event (Figure 2).
Figure 2: The new Intellisense tool tip displays the usage for each property, method, or event.
- New options for creating mobile computing applications include the ability to set device environment parameters to see how an application will perform under different device configurations.
- New visual guides help you align components on a form. In Figure 3, the Exit button is selected and is being positioned. The blue and purple lines appear as the button is aligned with other components or even with the text within another control (as is the case with the OK button shown).
Figure 3: New visual guides help you align components on a form.
Good Work, Microsoft
While most of the attention surrounding the release of Visual Studio 2005 is aimed at the new team development features and the new release of SQL Server, I find that praise for the Microsoft VS IDE development team is in order. They have, in my opinion, produced yet another fine program development system release.
Chris Peters has 26 years of experience in the IBM midrange and PC platforms. Chris is president of Evergreen Interactive Systems, a software development firm and creators of the iSeries Report Downloader. Chris is the author of The i5/OS and Microsoft Office Integration Handbook, The AS/400 TCP/IP Handbook, AS/400 Client/Server Programming with Visual Basic, and Peer Networking on the AS/400 (MC Press). He is also a nationally recognized seminar instructor and a graduate instructor at Eastern Washington University. Chris can be reached at
LATEST COMMENTS
MC Press Online