What are layer diagrams in Visual Studio 2010?

Posted: (EET/GMT+2)

 

If you are using Visual Studio 2010 Premium or Ultimate, you might be aware that your edition of Visual Studio contains modeling features. There are plenty of different model types available, starting from overall architecture and classic UML models, but this time I wanted to point out layer diagrams.

To add a layer diagram to your project, use the New Diagram command from the Architecture menu in Visual Studio, or press Ctrl+§,N. This opens a dialog box where you can create a new layer diagram. Note that you cannot find these diagram types from the regular Project/Add New Item command.

What, then, is a layer diagram? Shortly put, it is a logical drawing of the architectural parts of your solution. The drawing usually contains a box for each project in your solution, and lines between them. The main idea is to let the lines between boxes represent the valid references between the projects. You can then validate your whole solution against the diagram to see if it still complies with the original architecture.

For instance, if your data access layer (DAL) provides a class that your business logic layer (BLL) uses, you can draw a line between the DAL and BLL in your diagram. But if in your code your user interface (UI) layer accidentally directly references something in the DAL layer, the layer diagram validation can notice this and report an error.

There's a nice post about these layer diagrams in the MSDN Blogs. Be sure to check it out.