The Layer Diagram

The layer Diagram in VS2010 Ultimate is a great tool for validating your applications architecture. If you already have an application and you would like to see how your team has done following your prescribed architecture. Check this out.

Open your application in Visual Studio.

Then create a new Layer Diagram using the Architecture – New Diagram menu in Visual Studio Ultimate.

By dragging over layers from the tool box create a Layer Diagram that represents the architecture of your application.

Then Drag the components from your application in the solution explorer to the appropriate layer in the diagram. You can then open the Layer Explorer to see what layer everything is assigned to. (You can drag anything from a project to a single file.) Notice the numbers in the Layer diagram representing the number of items in that layer.


You could have created dependencies in the diagram to show which layer can call which layer. Since we are pulling in an existing app we want to see if it was written following our architecture. Therefore Right click on the diagram and select Generate Dependencies.

So here is how our application came out.

Most of the dependencies are fine. However there seems to be a lot of calls directly to the Data Layer. That is not good, but happens when the architecture is not validated periodically. click on the dependencies that are incorrect and press delete to remove them. Here is the Layer diagram as we intended it.

Now right click on the diagram and select Validate Dependencies.

This will generate errors and warnings where the application does not follow the architecture. So the Dependencies generated in the previous step now generate errors in the application.

From the error list you can generate work items in TFS to get these discrepancies fixed.

The bug will contain layer diagram that generated this error and the details of the invalid dependency.