Some Welcome Enhancements


Visual Studio 2005 and the .NET Framework 2.0 introduce literally hundreds of new features to an already full-featured toolset. In fact, it's hard to believe Visual Studio 2003 needed so many improvements. In fact, the language enhancements are fairly minimal. This latest version is about increasing developer productivity, reducing mundane tasks, and involving the full project team in the software engineering process. The following sections highlight those enhancements that promise to make your work life easier.

Of course, we will go over each of these items in greater detail throughout the book; think of this section as your "executive overview" for the hurried developer.

Note

We are deliberately focusing here on Visual Studio enhancements. We will cover the .NET Framework and the .NET languages (including enhancements) in the chapters that follow.


Design, Write, and Discover Code

Every developer wants to write great code. Nobody deliberately sets out to write a bunch of spaghetti code that is impossible to decipher, maintain, or extend. So how does so much code end up that way? Developers often lack proper training (aren't allowed the time off for training) and are under tight time pressures to deliver to production (or get home to their lives). The complexity is not going away; if anything, it is mounting even higher. Deadlines, timelines, project schedules, and project managers will still be driving you to release your work as soon as you possibly can. So how does Visual Studio 2005 help? It can offer guidance and "training" right within the editor. It can do routine and mundane tasks for you, the right way. It can free you to focus on your business problems and produce a higher quality product in a shorter time frame. The following sections highlight some of the promising new features that do just that.

Architect and Design Your Code First

Most developers will agree that having a solid architecture and visualization of your code will lead to a better overall product and development experience. More often than not, however, architecture documents are created at the beginning of the project (if at all) in a tool like Visio only to become quickly outdated during the build phase. It seems there is never time enough to go back and update the diagrams. You are left to watch them rapidly deteriorate into "original design" or "system vision" documentsnew labels put on what once represented the actual, physical structure of the application. Round-trip synchronization between the modeling tool and the development project was supposed to solve this problem. However, this solution was laden with its own issues: the principal among them is that developers want to see their code in their code window or IDE, not in yet another tool.

Visual Studio 2005 allows architects and developers to address this issue. Architects can work to create a full application design prior to cutting code. The modeling tools are built right into the IDE. Code and model are always in sync. The Class Designer, for instance, is simply a graphical view of your code. Edits within the designer are immediately reflected in the code and vice versa. The following sections describe the Visual Designers built into Visual Studio 2005.

Application Designer

The Application Designer allows architects to create a system definition model (SDM) that defines how different "applications" are combined for a given solution. An application in this sense refers to a website, web service, database, and so on. For example, a single solution might include a website that talks to a number of web services. These web services in turn might be communicating with a database or message queue. The Application Designer allows for this type of modeling. An architect can indicate which applications communicate with one another and can define the constraints between these relationships. Figure 1.1 provides a glimpse into the Application Designer.

Figure 1.1. An e-commerce application seen through the Application Designer.


Class Designer

The Visual Studio 2005 Class Designer provides a graphical means for writing and modifying your objects. You can use it to define classes and their relationships, add properties and methods to those classes, and modify elements within a property or method; it even allows for the refactoring of code. A change to a given method name within the Class Designer, for instance, will change the method's name as well as update all of the method's callers to use the new name.

An added benefit of the designer is that it enables the rapid discovery of code. With the Class Designer, you can drop a few key classes on a model, let the tool determine the relationships that exist in the code, and quickly discover (with visual reference) how an application works. Figure 1.2 is a snapshot of the tool in action.

Figure 1.2. The Class Designer illustrating objects and their relationships.


Logical Datacenter Designer

The ability to model your datacenter is a dream come true for streamlining communications between the infrastructure and development teams. Visual Studio 2005 allows you to define the boundaries within your datacenter (zones), the traffic allowed between these boundaries, and the servers contained within each boundary. In addition, constraints can be applied to items within this logical model, including versions of software on machines, types of traffic allowed on the machine, application pools, global assembly cache information, session state management, and the like. Finally, these models can be signed and versioned (as they seldom change), and the application design can be vetted against this logical model. Figure 1.3 represents the logical deployment zones of an e-commerce application.

Figure 1.3. A logical representation of the servers within a sample datacenter.


Deployment Designer

The application and Logical Datacenter Designers would be little more than pretty pictures if it were not for the Deployment Designer. This tool allows you to test your application's deployment against your logical datacenter. The tool verifies that you are allowed to make a deployment, allows you to drag and drop an application to a valid server, and verifies the deployment via a deployment compiler. For example, the tool does not allow you to place a web application on a database server that does not allow web traffic. In addition, during compilation, the deployment tool can determine whether the target server has the required software to run your application. Errors are output into a task list similar to coding errors. The intended effect is that deployment errors are found prior to moving code onto production servers, where errors can get very costly. Figure 1.4 shows the deployment diagram with the sample application deployed into the logical datacenter.

Figure 1.4. A test deployment of an application into the logical datacenter.


Invoke Activities from the Editor

If you live in a code editor, you can get in a zone where you never want to touch a mouse again. The rhythm of the keys is soothing as you pound out line after line of code. Having to reach up for a menu item or dig for a feature that might provide you some automation is not acceptable. Microsoft has learned that a number of features within Visual Studio go unused because they cannot be found or take too much time to access; it's often easier to just keep the rhythm flowing and fix things with the keyboard rather than go hunting for a feature. Microsoft has worked to align itself with these folks; just look at the latest incarnation of Word. The tool provides help where it can by underlining spelling and grammar errors; autocorrecting commonly misspelled words; and using smart tags where it recognizes people, dates, and addresses. Microsoft has worked to bring even more of these paradigms into Visual Studio. The tool now brings the help to you rather than forcing you to grab for the mouse and go exploring, losing precious productivity in the process.

AutoCorrect (VB Only)

A smart enhancement to the IDE for Visual Basic developers is the AutoCorrect feature. This feature makes good on the premise, "If the IDE knows what's wrong with my code, why can't it fix it?" If you code an error with the 2005 editor, you're likely to get a smart-tag glyph that, when highlighted, presents you with options for correcting the given error. Figure 1.5 shows the AutoCorrect feature presenting two options for a read-only property that has a public "setter."

Figure 1.5. Invoking the AutoCorrect activity from the code editor.


Snippets

Snippet-like features have been available in code editors for a long time now: macros, cut-and-paste, code library products, and so on. If you've sat through a few demos (and what Microsoft developer hasn't), I'm sure you've encountered a speaker relying on pasted code inside his or her toolbox to overcome typing deficiencies. This is a fine solution for very specific bits of code and one-developer scenarios. However, you have to remember both to create the code block and to use it. It's often easier to just start banging away at the keyboard using IntelliSense as your guide.

Think of the new snippet feature inside the Visual Studio code editor as an extension to IntelliSense that provides actual blocks of code to aid you with common programming tasks. A number of snippets ship with the product and, of course, you can easily create your own custom snippets (and share them with others). After using snippets for a short while, most developers will agree that having the snippet action part of the code window is an intuitive and welcome productivity enhancement. Figure 1.6 provides a glimpse of the snippet feature in action.

Figure 1.6. Code snippets automate common code blocks in an application.


My (VB Only)

The new My feature provides Visual Basic developers a speed-dial to a set of objects that provide common functionality to most applications. These objects, for the most part, wrap the .NET Framework and make it more accessible. Instead of navigating through the namespaces to determine how they might return the user's MyDocuments directory, for instance, VB developers can use the following:

My.Computer.FileSystem.GetDirectories( _   My.Computer.FileSystem.SpecialDirectories.MyDocuments)


The functionality exposed by the My feature is sure to make some C# developers jealous. Some classes allow access to the assembly name, the path of the executing code, an audio file on the computer executing the code, the mouse and keyboard, the network and ports, resource files, the event log, user objects, and settings, for example. There is enough speed-dial access to provide a measurable boost in productivity of these basic Windows tasks.

Discover and Navigate Code

Most of us have at one time or another been presented with an unfamiliar code base and told to make enhancements and fixes to the same. It typically takes a ton of time stepping through all the code to decipher the various relationships and complexities that exist within. Tools like the aforementioned Class Designer can be a big help. In addition, the new features of Visual Studio 2005 described in the following sections will aid in the rapid navigation and "learning" of a code base.

Code Definition Window

When you're navigating code, you'll often run into a type that you need more information on. You might want to view the code behind the type to see how it is implemented. Previously, to jump between types, you either hunted for their underlying code files or used the Go to Definition from right-clicking on a given type. Visual Studio 2005 provides another tool: the code definition window.

Invoking this window splits the code editor between active code and a read-only view of referenced code. For example, if you are coding a class called Shoe that inherits from the abstract base class Product, you might want to be able to see the Product class without jumping from file to file. Figure 1.7 shows the code definition window doing just that.

Figure 1.7. The code definition window allows a split-screen view of the active code editor and the code of its referenced types.


The code definition window is more than just a read-only view of referenced types. It allows you to clip text for pasting into your code; you can set breakpoints and bookmarks in this view as well. Of course, you can also easily jump to the actual code displayed in the code definition window by right-clicking and then choosing Edit Definition.

Class View Search

A new (and welcome) addition to the class viewer is search. It can be challenging to find the class you are looking for when working with thousands of lines of code across hundreds of classesespecially if your class files contain multiple classes within each file. In addition, you often need a quick search of the .NET Framework classes within the IDE. The class view search feature provides a means to quickly find all classes matching a given string. For example, Figure 1.8 shows a search for the string "Product".

Figure 1.8. Class view search enables you to quickly find types within projects and/or the .NET Framework.


Find All References

Another great code navigation enhancement is Find All References. This option, available from a right-click on a given type, uses the compiler (not string checking) to find all the code files and locations that reference a given type. Figure 1.9 demonstrates this feature by searching for all references of a class called Product.

Figure 1.9. Find All References uses the compiler to find all uses of a given type.


Edit and Debug Code

When the code canvas is clean, there is nothing but opportunity staring us in the face. Some developers see this is a daunting task, whereas others (myself included) relish in creating something completely new. However, this is becoming more and more the exception to the average coding experience. Today's developers spend very little time doing fresh development. Instead, they tweak, modify, and enhance existing code. In doing so, they are often required to trace through the code and find glitches and the spot to apply the appropriate patch. Microsoft has put a lot of effort into improving this important part of everyday development. The following sections provide the highlights.

Refactoring (C# Only)

Developers often notice enhancements they would like to make to the readability of their code or to increase the probability of reuse or to eliminate duplication of similar code. This process is called refactoring. There's been a lot of talk around refactoringespecially as it relates to agile methods (write tests first, write code to satisfy tests, and then refactor to streamline the code base). The biggest issue with refactoring has been trying to make changes to a somewhat stable code base. Sweeping changes are okay in the initial development. However, the last thing anyone on the team wants as you move toward your production date is a change that might introduce more bugs into the code.

To aid in this dilemma, the Visual Studio C# editor provides a number of options for refactoring. It is possible with these tools to simply rename a method, for instance, and be assured that all code that calls that method will be changed. As another example, suppose you have a class that you would like to use as a model for a new class. You might want these classes to be based on a common interface. With the refactoring tools, you can simply extract the existing class as an interface and then implement that interface on the new class.

The refactoring engine uses the compiler to ensure proper and complete code coverage. It also searches comments and makes the proper changes there! In addition, it allows you to preview the changes as they are made (at least until you are comfortable with allowing the tool to modify your source). Refactoring features include all of the following:

  • Rename Allows the renaming of a fields, properties, methods, variables, and the like.

  • Extract Method Allows for the creation of a new method using existing (selected) lines of code within a given method.

  • Promote Local to Parameter Allows you to take a local member of a method and promote it to a parameter of the method. The tool will also work to update any callers of the method.

  • Reorder Parameters Allows for changing the order of parameters on a given method signature.

  • Remove Parameters Allows the removal of a given parameter from a method. This feature works to update the callers of the method to remove the value passed to the parameter.

  • Encapsulate Field Allows for quickly generating properties from a given field.

  • Extract Interface Takes an existing class or struct and generates a matching interface, allowing the type to now implement that interface.

The refactoring feature is invoked from either a right-click or a smart tag. The smart tag allows for automatic refactoring without searching for the feature. Figure 1.10 shows the refactoring tool moving through a series of changes in preview mode.

Figure 1.10. The refactoring tool allows for the preview of changes prior to execution.


Refactoring for the VB Developer

Members of the Visual Basic development community were very outspoken when they heard they would not be getting the benefits of refactoring built into Visual Studio 2005. Fortunately, a third-party development house, DevExpress (www.devexpress.com), struck a deal with Microsoft to include a version of its product for all VB .NET developers.


Edit-and-Continue

Undoubtedly, the first thing you noticed when debugging your application, if you switched to .NET from a previous incarnation of Visual Basic, was the absence of edit-and-continue. You could no longer make a change in the debugger and continue to step through your code. Rather, you were forced to stop the application, make the change, recompile, and rebreak into your code. This was no small change for the VB folks out there, many of whom had incorporated edit-and-continue into their programming style. They might bang out the vast majority of their code and rely on a very long debug session to get the rest completed.

The good news is that edit-and-continue during debugging is back. There are some limitations (there were in prior VB versions as well), but for the most part you can make a change and keep on stepping. The better news is that this feature is not limited to VB: C# and C++ developers can also take advantage of this productivity enhancement.

Visualizers

Visualizers are another one of those features that will have you wondering how you lived without it. Imagine the last time you were trying to debug a problem with your data-driven application. Everything seemed right, so you figured the data must have been bad. Of course, it is almost impossible to see the data from the debug window. You either dig through a massive series of trivial properties, or you punt and jump out to a SQL window.

Now, with visualizers you can easily see the contents of a dataset represented as a tableright within the IDE in debug mode.

Visualizers allow for the meaningful, visual representation of a variable in debug mode. Visualizers can be invoked from DataTips, the Watch window, the Autos window, or the Locals window. Visualizers exist for data, XML, and HTML. There is also full support for writing custom visualizers and installing them in the IDE. Figure 1.11 shows the DataSet visualizer in action during a debugging session.

Figure 1.11. A visual representation of a dataset in debug mode.


Additional Debugging Enhancements

The number of enhancements to the Visual Studio debugging experience is astonishing. We've already highlighted a few but would like to briefly bring a few more to your attention. The following sections describe some much-needed improvements to the .NET debugging experience.

IntelliSense in the Watch Window

You can now more easily add items to the Watch window simply by typing in the variable and navigating the underlying object model using IntelliSense right within the Watch window.

Improved Remote Debugging

Microsoft has greatly improved the setup of remote debugging. You now need to deploy only a single file to the remote machine to enable remote debugging. Microsoft has also worked to make sure it is a secure feature.

DataTips

You've had the ability to hover over a variable in the editor while in debug mode but were limited to a single string of text for display. DataTips provide the capability to present more data and allow you to drill into that data (similar to QuickWatch) right from a mouse-over.

Tracepoints

A new and improved breakpoint system in Visual Studio 2005 offers both better breakpoint management as well as the ability to create tracepoints. A tracepoint is a breakpoint that allows for a custom action to be executed when the code hits the tracepoint. Custom actions come in the form of printing a message to the output window or running a Visual Studio macro. It's nice to be able to write out trace messages during debugging without littering your code with trace statements.

FxCop Built-In Support

FxCop was an often underused code-analysis tool. I recall visiting one developer shop after another and finding out they had never heard of the tool or what it did. It checks a number of rules, including those surrounding naming conventions, performance enhancements, globalization violations, and design guidelines. You can turn rules on and off or even write your own rules.

The problem was FxCop required a download from Microsoft's GotDotNet site and installation on machines. The good news is that Microsoft has extended FxCop and built it directly into the IDE. You can now turn on code analysis from within a project's property page and start getting suggestions on improving your code. Figure 1.12 shows the rule settings of FxCop along with sample warnings generated from a compile.

Figure 1.12. FxCop code analysis in action.


Share (and Consume) Code with a Community

Writing code is often a community thing. The developer community is broad and, for the most part, supportive of one another. Chances are, if you are having a problem, someone else has had the same issue. You can often reach out across the Internet and find solutions, components, sample code, articles, and the like that help to solve your issue. There is some kinship among developers that attracts them to posting sample code, newsgroup answers, and tips. Perhaps it is as simple as knowing that they may be the next in line to need an answer to a critical question, or maybe it's just the need to show off to one another. Either way, Microsoft has worked to extend the community atmosphere that pervades .NET.

New for 2005 is the ability to search communities (from within the IDE) for project templates, code snippets, samples, controls, starter kits, and add-ins. Microsoft has created a packaging and installation system surrounding .NET community content. You can now easily create new project templates, post them to community sites, find them within the IDE, and install them into your environment for use. See Chapter 12, "Writing Windows Forms Applications."

Target Different Customer Experiences

.NET has quickly become pervasive throughout the entire Microsoft product world (third-party vendors included). It took only a few short years, but it is now fair to say that .NET is everywhere; Windows programming and .NET programming are now synonymous.

As proof, we now have Windows Server 2003 with .NET built-in; we have a new version of SQL Server with support for hosting the .NET runtime and writing data access code as .NET code. The latest versions of Microsoft's server products like BizTalk and Commerce Server are built using .NET. The next version of its flagship operating system (codenamed Longhorn) has .NET embedded throughoutmy cell phone is even running a version of the .NET Framework! Every application vendor on the Microsoft platform has a .NET version; we could go on and on. The point is that it is a great time to be writing .NET code. You can target so many solutions with a single framework!

The following sections highlight a number of the customer experiences you are able to target using Visual Studio 2005 and the latest version of the .NET Framework. In addition, Figure 1.13 shows the New Project dialog box in Visual Studio; it now represents the myriad of solutions that are possible with .NET.

Figure 1.13. The many application faces of Visual Studio 2005.


Smart(er) Clients

Smart clients are rapidly becoming the user experience of choice for the business application. What smart client means, on the other hand, is still a topic of debate. The debate waivers between two principal ideals. The first represents a rich, windows-based UI application that is deployed and works across the Web, can work in a disconnected mode, understands how to update itself, and plays well in the security sandbox. The second is an application that uses MS Office as the user experience and combines some level of business functionality over the network.

Whatever your view of what makes a smart client (fundamentally, the two are not all that different), the good news is Visual Studio 2005 provides better support for both. The former representation (combination thick client and web application) is really an application design pattern. However, this pattern would not be as easy to create without things like click-once deployment, code-access security, support for disconnected data (and reconnecting that data), web services, and remoting infrastructure. The latter now has full support from within the IDE in the form of Visual Studio Tools for Office (VSTO for short).

Of course, we've been able to customize Office for a long time now; some of us still remember writing Excel macros on Windows 3.1 or automating Word with Word Basic. Visual Studio 2005 marks a new era for Office development with the complete support of building on the Office platform from within the Visual Studio 2005 IDE. With VSTO, you can now create Office-based projects and solutions inside the tool. This includes support for creating Word, Excel, and Outlook first-class projects. Figure 1.14 shows an Excel/C# solution within Visual Studio 2005.

Figure 1.14. Visual Studio's support for Office applications.


Note

Building Office applications with Visual Studio 2005 requires the professional edition of Microsoft Office.


Smart Devices

Visual Studio 2005 extends your power to write applications that target mobile devices. You are free to target PDAs and mobile phones. The IDE provides UI, code, and debugging support for these applications. In addition, you can write both standard, forms-based mobile applications as well as ASP .NET mobile applications with the ASP .NET Mobile Designer. Figure 1.15 illustrates a standard SmartPhone application being developed leveraging Visual Studio.

Figure 1.15. Visual Studio's support for targeting a SmartPhone.


Web Applications

There are major changes (and advancements) in store for web developers. Clearly, the vast majority of applications built these days involve some semblance of a web componentbe it a full-blown browser-based, web application; a smart client that works across the Web; a web service; or otherwise. The point is that the majority of developers writing .NET code are targeting the Web at some level within their solution. It seems that Microsoft has remained heavily focused in this area for just these reasons. It is clear Microsoft has made another big investment in enhancing the web capabilities of .NET. We highlight some of these advancements in the following sections.

A Full Toolbox

One of the first things you notice about ASP .NET is that there are many, many more controls than we web developers are used to (unless you've been purchasing third-party control libraries). The standard set of controls is still available for creating labels, text boxes, buttons, and the like. Of course, there are enhancements to these controls as well as some new standards like the Wizard control for creating web-based wizards or the MultiView for managing varied groups of controls that are influenced by user preference or identity.

Things get real interesting in the all new sets of controls. For instance, there is now a complete set of data controls including the GridView that takes the concept of the DataGrid to new heights. There is also the new ReportViewer control for displaying data as a report. There are new data source controls including an ObjectDataSource for binding directly to object data stored as a list or collection. Moving beyond data controls, there is a new SiteMapMath control that tracks a user's progress as he or she navigates through the various levels of your site and allows the user to jump back up the chain. There is an entirely new set of controls to manage user login to websites. Finally, if you've ever used SharePoint Portal Server, you have undoubtedly worked with zones and Web Parts. They allow users to define where functionality exists within a given page. Visual Studio 2005 ships with a similar set of Web Part controls for designing similar features into your application.

A Manageable User Experience

It seems the user experience (look and feel) of a website tends to evolve independently of the actual functionality of a site. Perhaps marketing is looking to keep the site fresh or inline with the latest campaign. As web developers, we have been planning for this for a long time with things like style sheets, include files, and user controls. ASP .NET 2.0 gives web developers additional tools for managing the user experience, namely themes, skins, and master pages.

A theme is a group of appearance properties that can be applied to an entire site, a given page, or a single control. You define themes based on common appearance properties that a page will contain (including images). For this reason, appearance properties are common across pages and controls in ASP .NET 2.0.

Creating a new theme is as simple as adding a new folder in your site's App_Themes directory. You then add theme-related files to the directory like a style sheet, images, and skin files. Skin files are new to ASP .NET 2.0. They enable you to define the look of a given control, such as a GridView, for your entire theme. With this feature, you can ensure all controls of a given type look identical across the site. You apply the theme to your entire website via a setting in the config file. Alternatively, you can apply a theme to a single page using the page directive's theme attribute.

Master pages evolve the include files and user controls of old to enable you to visually inherit portions of a master page. When you create a master page, you are defining the elements of the page that are common to all pages that derive from the master. Typically, this includes a header, some form of navigation, and a footer. In addition, the master page defines content areas to which subpages can add their functionality. Finally, this entire concept is supported visually through the Visual Studio designer. You can now see the layout of your pages during design! Figure 1.16 shows a subpage being created in the designer; the grayed-out areas are those common to the master page.

Figure 1.16. The designer view of a web page inheriting from a master page.


A Development Server

To test and debug applications effectively, most .NET web developers run a local copy of Internet Information Server (IIS) on their development machine (typically a Windows XP Professional box). The operations and infrastructure teams have typically turned a blind eye to this. However, as security becomes a bigger and bigger focus, a series of developer-hosted web servers on the network becomes difficult to manage at best and a security vulnerability at worst.

Solving this problem can be challenging; it often requires shared servers, remote debugging, or some level of virtual development. Each of these solutions has its own drawbacks. Chief among them is that the web developers can no longer cut the cord to the network and still be cutting code.

Visual Studio 2005 ships with a new tool to aid with this issue: ASP .NET Development Server (not a catchy name but effective nonetheless). This server has it roots in the server named Cassini that shipped with the free ASP .NET Web Matrix. With it, you are free to test your code locally, independent of IIS. Of course, the best feature is that it only serves pages to the local box; it is invisible on the network.

This server is not IIS. The biggest issue in this regard is that the ASP .NET Web Development Server runs with your local user credentials. Getting the security right will still require a walkthrough when you push things up to an IIS build or test server. Of course, you still can run a local copy of IIS on your machine if you prefer.

Connect with Data

Many of the advancements that .NET 2.0 makes relative to connecting with your data come in the form of easier-to-use, more connected tools and controls. There are a few advancements with respect to various data namespaces (System.Data, System.Data.SQLClient, and so on). However, the vast majority of improvements lie in the way Visual Studio and the new controls are working to bind to this data. The following sections describe some noticeable enhancements to the development experience.

Zero-Code Data Binding

Whether you are writing a new web form application that connects directly to your database or you have a three-tier application that delivers data to web controls via business objects or web services, Visual Studio makes great strides to automate this entire process. Visual Studio recognizes multiple data sources including business objects and lists, databases (SQL, Oracle, and others), XML, and web services.

Windows Forms

Windows form developers can simply add a data source to their application and make use of the tables and their relationships via drag-and-drop to a form. Visual Studio determines which data maps to which control (date data to calendar control, for instance) and how the data gets displayed in the form of parent-child relationships. Of course, you have complete control to override this information. Figure 1.17 shows a Windows form under development that connects users to orders and order details. The form is fully functional without writing a single line of code.

Figure 1.17. Zero-code data binding on a Windows form.


Web Forms

Developers of web forms have similar options for binding to data through the use of controls. A host of new data source controls allow for the configuration of a data connection (shared or otherwise) and the ability to work that data. Data source objects allow for defining selects, inserts, updates, and deletes across a variety of providers. Data source providers include the SqlDataSource object (used to connect to databases whether they are SQL Server or otherwise), AccessDataSource, ObjectDataSource, XmlDataSource, and SiteMapDataSource. Figure 1.18 shows the dialog box for defining an insert query to a SqlDataSource. Note that each parameter on the query can be linked to a control on the form (or the session, querystring, cookie, and the like).

Figure 1.18. Data binding an insert query of a SqlDataSource control.


In addition to the data source objects, there are both new and improved controls that ease the burden of binding to and working with data. A new GridView control makes the process of working with lists of data much easier. The new FormView control allows you to build dynamic forms based on the rows in a database. Most ASP.NET controls now have a means to bind directly to a data source through the IDE. For instance, the DropDownList control allows you to pick a data source and to define a field that is displayed to the user and another whose value is posted to your code.

Automate Application Testing

Visual Studio 2005 empowers developers with testing tools to better ensure the quality of their code prior to deployment. These tools include automated unit testing, syntax checking, code coverage analysis, integrated FxCop features, object test bench, and more. As an example, developers can let Visual Studio generate unit tests based on their code base. This may fly in the face of test-driven development's mantra of test-first development, but it ensures a higher likelihood that tests will be developed for an application.

Developers may end up submitting a higher-quality product to the quality assurance team, but if you've spent time in this camp, you know what a manual, routine process this can be. Visual Studio now gives testers an arsenal of tools to call their own. You can write and track test cases, generate test coverage reports, track issues (and report on the same), execute load testing, and more. Figure 1.19 provides a glimpse into the features designed for testers. You can see the Test Manager screen in the background and the new test menu in the foreground.

Figure 1.19. The Test Manager and the new test menu.


Finally, Visual Studio includes a new build engine that can be configured to execute tests when developers check in their code. If, for instance, you require the code not to break the build, you can configure an integration test to pass as part of the new build engine.




Microsoft Visual Studio 2005 Unleashed
Microsoft Visual Studio 2005 Unleashed
ISBN: 0672328194
EAN: 2147483647
Year: 2006
Pages: 195

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net