Generating Dependency Graphs

Another interesting addition, new to VS 2010, is the Dependency Graph generation. Basically this feature enables generating a WPF-based, graphical, browsable view of dependencies between objects in your projects. Dependency graphs can be generated at assembly level (including all types), namespace level (including only types from a given namespace), or at class level. To demonstrate this feature, create a new console project and add the following items:

• An Entity Data Model mapping the Customers, Orders and Order_Details tables from the Northwind database (see Chapter 27, “Introducing the ADO.NET Entity Framework,” for a recap).

• A new class named Helper, whose purpose is just offering a simple method returning a collection of order details based on the order identifier. The code for this class is shown in Listing 58.5.

Listing 58.5 Demo Class to Be Mapped into the Graph

image

Now select the Architecture, Generate Dependency Graph, By Assembly command. After a few seconds the new graph will be available inside Visual Studio 2010. You can then expand items and check for their dependencies with other objects, as represented in Figure 58.22.

Figure 58.22 The newly generated assembly-level dependency graph.

image

To understand items mapping you can check out the legend. To show complete dependencies information, right-click the graph and select the Show Advanced Selection command. This launches the Selection tool window where you can select one or more objects to be investigated and additional objects to be analyzed such as public or private properties. Figure 58.21 shows public properties dependencies from all classes in the project. For example, the NorthwindEntities class has dependencies with the Helper.GetOrderDetails method because this one receives an argument of type NorthwindEntities. The dependency graphs are flexible and can be exported to XPS documents or to images (right-click the graph for additional options).

Summary

This chapter covered some important analysis tools available in Visual Studio 2010 Premium and Ultimate that are necessary for improving applications’ quality. You discovered how to analyze code for compliance with Microsoft coding rules, required especially when you produce reusable class libraries. Then you saw how to check for code maintainability using the Code Metrics tool. In the second part of the chapter you got information on the integrated Profiler that simplifies checking for performance issues through IDE suggestions; you also saw different usages of the Profiler, including standalone executables. The chapter also focused on the most interesting addition in Visual Studio 2010, the IntelliTrace debugger. Explanations provided information on using this tool for understanding how to keep track of all application events and exceptions during the entire application lifetime, showing also how to analyze summary logs within Visual Studio. Finally, you got an overview of another new addition, the Dependency Graph generation that provides a graphical view of dependencies at assembly, namespace, and class levels.

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

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