Articles tagués layer diagram visual studio
Using architecture Diagram with visual studio ultimate 2010, architecture check
Publié par hassanboutougha dans Architecture diagram, Sofware Architecture le décembre 17, 2012
We create a simple 3 Layered architecture application with presentation layer for GUI, business Layer to do our business process and Data Access Layer to get our data from different source. The purpose is to check that each layer call the layer below and if not a tool (here architecture diagram ) can detect that someone doesn’t follow architecture rules.
The solution explorer show three project (one console project as presentation layer and the two others are library project:
The DataLayer project contains Data.cs file where data access is implemented:
the business layer in a process call data access layer to make some work:
with a reference on Data access layer assembly
finally, the presentation layer call the business process and show result in a console output:
with a reference on layer below that is business layer
use Architecture ->Generate Dependencices diagram by Assembly :
you obtain a dependency graph:
we see that Presentation Layer calls business which calls DataLayer.
We want to set architecture rules, so go to Architecture -> new diagram and select Diagram Layer:
click ok and set a name to your model project which appears in our solution explorer:
in toolbox on the left panel select layer and drag and drop on diagram three times as follows:
rename each layers to have presentation, business and data layer:
Drag and drop each project on its layer (Presentation is dragged and dropped on Presentation layer and so on…) a number at the right side of the layer appears to show that the layer is associated to a project 😉
now generate the dependencies we want to keep :
Visual studio create dependencies at layer level for you 😉
arrows show all dependencies (Presentation calls Business which calls Data layer)
Suppose now our software developper friend who call from presentation directly Data by setting a reference on data assembly and call our data method which is prohibited:
You are the architect (waw you have a good job ;-), and you want to quickly check that the architecture is followed and if not you want to have an alert. Go to the Layer diagram, then call Validate from the context menu
Now we have three errors showing where the architecture is not followed as expected:
Correct it by retrieve the modification of your bad friend (code and Data reference if not your bad friend will loose his job and will ask you to let him sleep at your home ;-( ), and run Validate Architecture again:
all is good so enjoy and show this article to your manager to get the ultimate version of visual studio 2010 😉