Click here to Skip to main content
15,867,834 members
Articles / Programming Languages / VC++
Article

Dive into Architecture with DeepEnds

23 Sep 2016CPOL 21.1K   15   7
Dive into Architecture using the open source Visual Studio Community 2015 extension (VSIX) DeepEnds.

Introduction

Some time ago, I wrote an article for CodeProject on performing dependency analysis. I gradually extended the Python code and examples and placed them on GitHub. Subsequently, I agreed to talk about architecture for a local .NET meetup so, for greater relevance, I wrote a tool to decompile .NET assemblies with Mono.Cecil. I've since recorded most of the Python into C# to create the Visual Studio extension DeepEnds that is available via the Visual Studio Gallery. One advantage is that it uses Roslyn to parse the individual C# and VB files.

Visual Studio Enterprise 2015 includes a number of architecture tools whose results can be visualized within the Community and Professional editions. Of particular interest is the DGML file format for describing directed graphs (used to visualize dependencies) as these files can be viewed in Community. I believe the DGML viewer uses the Microsoft Automatic Graph Layout library to do the actual drawing, thus it should be possible to create a standalone viewer.

The source code for the plug-in is available on GitHub for those wishing to see example code for parsing C# and Visual Basic source in Roslyn, decompiling assemblies with Mono.Cecil or using the Visual Studio API to create DGML files.

DeepEnds

DeepEnds allows you to dive into your architecture without having to dive deeply into your pocket... i.e. It has been developed for Visual Studio Community 2015 and is distributed gratis. It uses the same concepts for visualizing dependencies and calculating associated metrics as described in "As-Is Software Architecture" and "Why Favour the Cyclomatic Number?", so they won't be repeated here.

To launch the tool from the menu bar choose View → Other Windows → DeepEnds; the tool window is very simple. The first text box is multi-line and takes a set of input files, one-per-line, that can be appended to by using the associated browse button. Once the required files are determined the read button needs to be pressed. The second text box is single line and specifies the creation of either a DGML file or the associated HTML report once the write button is pressed.

The tool window

There are some limitations on the input: Cannot mix C++ and .NET. The decompilation of assemblies will not produce as good a result as parsing the C# or VB source code.

As mentioned, the main form of output is a DGML file which happens to be a collapsible hierarchical graph format which supports hyperlinks to code as can be seen by the underlining of the text of the leaf node (FEA.cpp) in the following diagram. The hierarchy is defined by the namespace for .NET and by the filter for Visual C++. Note that it is possible for the user to edit this diagram interactively.

The DGML window

This can be compared with the Doxygen output (generated as a png file using the dot tool) from my previous article.

Doxygen output

The second form of output is an HTML report that starts with a table of complexities ordered so that the worst is first. The sum columns refer to the formula to their left that is evaluated for the current and all child nodes, recursively. Thus it is possible to get one value for the project and to track that over the course of development.

The externals column refers to the number of unique dependencies that aren't contained by the current node. Thus the Top Level node will always have a value of zero. The maximum on the node and all its children is tracked for completeness. This measure is equivalent to Class Coupling in Microsoft Code Metrics.

For instances other than decompiled code, the number of lines of code in a leaf node are counted. Thus comments (but not C style comments) are ignored along with braces in C++ and C#. The sum and maximum calculated over the current and child nodes are reported along with the arithmetic mean.

Finally, whether a cycle exists within the graph is reported.

HTML output

This table hyperlinks to sections that detail the underlying dependencies that cause the links to be displayed in the graph. For example, FEA\Core should not be dependent on anything so it is useful to see what is creating the circular dependency (so that it can be broken) by looking at the appropriate section.

HTML output

There are further tables of the external dependencies, the individual SLOC and the structure matrix.

Batch Mode

Additionally, there is a console application called DeepEnds.Console.exe. Run it with no arguments to get usage instructions. Note that extensions (*.vsix) are just an archive if you cannot find where Visual Studio has installed the extension.

Final Note

So, if interested, please download and install. It should work for Visual Studio Professional 2015 as well as for Community.

History

  • 2016/07/29: First release
  • 2016/08/11: Update due to new version of software - can now mix C# code and .NET assemblies
  • 2016/08/15: Update due to new version of software - added support for VB.NET source code
  • 2016/08/24: Push source to GitHub
  • 2016/09/14: Update with new statistics

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United Kingdom United Kingdom
Mathematician turned freelance Software Engineer with over 20 years experience, mainly in the development of CAD/CAM/CAE software. Generally worked for smaller businesses - although have been at Lloyd's Register, Siemens and Rolls-Royce. Enjoy living on the edge of the Peak District where I go cycling and hiking.

Comments and Discussions

 
QuestionNo result Pin
Ehsan Abidi Ashtiani15-Aug-16 21:39
Ehsan Abidi Ashtiani15-Aug-16 21:39 
AnswerRe: No result Pin
Zebedee Mason17-Aug-16 2:15
Zebedee Mason17-Aug-16 2:15 
GeneralRe: No result Pin
Ehsan Abidi Ashtiani23-Aug-16 18:38
Ehsan Abidi Ashtiani23-Aug-16 18:38 
GeneralRe: No result Pin
Zebedee Mason24-Aug-16 4:56
Zebedee Mason24-Aug-16 4:56 
GeneralMy vote of 5 Pin
Member 1236439014-Aug-16 21:35
Member 1236439014-Aug-16 21:35 
GeneralRe: My vote of 5 Pin
Zebedee Mason14-Aug-16 23:38
Zebedee Mason14-Aug-16 23:38 
QuestionHave you consider to post this as a tip? Pin
Nelek11-Aug-16 2:17
protectorNelek11-Aug-16 2:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.