Articles tagués check architecture dotnet

Using architecture Diagram with visual studio ultimate 2010, architecture check

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:

solutionexplorerdiagarchi

The DataLayer project contains Data.cs file where data access is implemented:

datalayer

the business layer in a process call data access layer to make some work:

businesslayer

with a reference on Data access layer assembly

businesslayerreferences

finally, the presentation layer call the business process and show result in a console output:

presentationlayer

 

with a reference on layer below that is business layer

presentationlayerref

 

use Architecture ->Generate Dependencices diagram by Assembly :

generategraphdependencies

 

you obtain a dependency graph:

dependencygraphbyassembly

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:

layerdiagram

click ok and set a name to your model project which appears in our solution explorer:

Modellayerdiagram

 

in toolbox on the left panel select layer and drag and drop on diagram three times as follows:

layerdiagramtoolsbox

 

rename each layers to have presentation, business and data layer:

layerdiag1

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 😉

layerdiagassociatedwithproject

now generate the dependencies we want to keep :

generatedependencies

Visual studio create dependencies at layer level for you 😉

generatedependenciesdialog

arrows show all dependencies (Presentation calls Business which calls Data layer)

layerdiagwithdependencies

 

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:

badfriendwithbadcode

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

validatearchitecture

Now we have three errors showing where the architecture is not followed as expected:

architectureerrors

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:

architecturegood

 

all is good so enjoy and show this article to your manager to get the ultimate version of visual studio 2010 😉

, , , , ,

1 commentaire

Microsoft System Center 2012

All System Center 2012 products, Service Manager, App-Controller, Orchestrator, Virtual Machine Manager, Configuration Manager, Data Protection Manager, Operation Manager -Boutougha Hassan

Microsoft Windows Server 2012

IT - Windows server 2012 - Hassan Boutougha

Microsoft Hyper-V

IT - Hyper-V - Hassan Boutougha

Microsoft SQL Server 2012

IT - SQL Server 2012 - Hassan Boutougha