Visual Studio 2010 and .NET 4.0 are indeed a big wave of release since it incorporates numerous of features and improvement which could not be discussed in a short time. One of the major new feature is the architecture feature which I’ll discuss it on this and subsequent series of blog post. As the starting post, I’ll write about one of the interesting feature, namely Dependency Graph.
According to wikipedia, a dependency graph is a directed graph representing dependencies of several objects towards each other. It is possible to derive an evaluation order or the absence of an evaluation order that respects the given dependencies from the dependency graph. Dependency Graph has been widely used in many field including mathematic, computer science, digital electronics, as well as software design.
In software design, we can utilize Dependency Graph to analyze the dependency of one functional component with the others. In more advanced, we even could determine the level of dependency. It is usually used by a software architect, to see how the entire system behave with respect to dependency. Thus, it may let the architect understand which is the most critical component or what’s the consequence if we remove the particular component from the system.
Prior to Visual Studio 2010, it’s actually possible to preview a dependency graph by either using add-in software such as NDepends or independent software such as Dependency Visualizer . However, it somehow requires additional effort to search, choose, buy, install, configure the software in order to achieve what we actually intend. Yet, it sometimes still could not fulfill our requirement.
(NDepend)
(Dependency Visualizer)
It’s a good news that the Dependency Graph feature is now available in Visual Studio 2010. Dependency Graph in VS2010 serves as a snapshot of the dependency of each components in our solution. Now, let me use one of the all-time favorite .NET blog application as the example in this sample, namely the BlogEngine.NET. For information, BlogEngine.NET is open source blogging engine application that you could be download here in codeplex. Since we need the full source code, please click on “download BlogEngine.NET (source)” on the download tab.
Having completed downloading and extracting the source code, the next step is to open up your Visual Studio 2010, navigate and open to the solution (.sln) file. As expected, VS2010 will launce a wizard dialog that prompting us to convert our application to .NET 4.0 since the source is actually developed with previous version of Visual Studio. As such, just click on next to complete the converting wizard. If everything is fine, you will see the following screenshot of solution explorer like this.
Now, let’s get ready to explorer the dependency graph features. To start, click on the Architecture menu on the menu bar, and click on Generate Dependency Graph. You will see there are a few level such as By Assembly, By Namespace, By Class, or Custom… You are free to select which level you want. In this example, I’ll choose By Assembly. Immediately, VS2010 tries to generate the dependency graph for us based on each namespace in our solution as seen on the following diagram.
The nodes denotes the component at certain level. On the highest level, it is a assembly. Subsequently, it could be a namespace, class, or event method or properties. You can mouse-hover on each node to see more detail information about it. In addition, you could double-click on the node, and then it will bring you to the exact definition in code view.
The Arrow-line denotes the dependency between one component and another. If A –> B, it means A has dependency to B. In other words, A uses some library or service or method in B.
If you notice some line is thicker than the other. What does it actually mean? It identify the depth of dependency of component to another. The thicker the line, the higher depth of dependency it is. It thus enables architect to understand the depth of dependency among each component.
If you notice, there’s one special node namely Externals. The Externals node is a package that group other components outside our solution however they relate with our solution. It includes component such as third party product or services.
Each node (in the example: assembly) could be expanded in more detail by only clicking the down arrow button located on the top right corner of each node. The following picture illustrates the detail namespace. Moreover, each namespace is also can be expanded into classes and so forth until the smallest unit of code.
We can navigate the either scrolling the mouse. To zoom in and out, we could use the Ctrl + mouse scroll.
The graph itself could be displayed in various view and it is adjustable on the architecture toolbar
We can arrange the display to Left to Right, Right to Left, Top to Bottom, Bottom to Top, as well as Quick Cluster which result the nodes are arranged in better position.
It’s possible to focusing only on certain diagram. Simply clicking on each node and click the Neighborhood Browse Mode. Notice that you are free to select whether you want to show only other nodes that has n (1 or 2 or 3, etc) links away from the selected node. In other word, if I select 1 link, the graph will only return all nodes that has one direct level or relationship link. If I select 2 links, the graph will return me all of the second level neighborhood node.
In addition, Visual Studio 2010 offers an analyzer feature which enable us to either find circular reference, hubs, as well as unreferenced nodes. To do this, right click on any where at the graph and select Analyzers and type of of analyzer you like to do.
1. Find Circular Reference
In many case, we are advised to avoid circular reference as it possibly could create confusion as well as deadlock.
2. Find Hubs
Hubs refers to nodes that have many references to other resource. Why do we need to know “hub”? It helps us identify which nodes are important and heavily used. Any modification on them should be carefully done.
3. Unreferenced Nodes
By filtering Unreferenced nodes, we are now able to see which nodes are acting as consumer and not dependent. So, what’s the big deal of this? It’s of course could let us know that the nodes are modifiable without need to consider to much about dependency since there’s no other component depends on them.
What’s on the scene behind of the graph actually? Similar with dbml in LINQ to SQL or edmx in Entity Framework, it’s actually an XML-based file called DGML (stands for directive graph markup language). DGML is actually all about nodes and link, how a node is connected to another by link. To see it, you can right click on anywhere of the graph and click on View DGML.
That’s all about the dependency graph. I’ll continue to write other architecture features in VS2010 in the following posts. Any comments are welcomed .
Pingback from BMWs Gull Wing 4 seater Diesel hybrid concept car | Gull-Wing Door Coachwork Design
Pingback from MotorhomeIreland.ie:: | Line Graph Of The Weather http…
Pingback from Yoga Weight Loss a Healthy Alternative ?? Yoga for life | Yoga Beauty Wisdom
Pingback from Twitter Trackbacks for Architecture Features in VS2010 (Part 1 ??? Dependency Graph) - Wely Lau [netindonesia.net] on Topsy.com
Pingback from MotorhomeIreland.ie:: | VTS_01_1_xvid.avi http://bit.l…
Pingback from antonalfer.livejournal.com – The Beauty Hunter | Business Beauty Wisdom
Pingback from MotorhomeIreland.ie:: | Homes Accommodation Ballinrobe…