Derik Whittaker

Syndication

News


Validating Application Architecture with Visual Studio 2010 – Layer Diagrams

One of the pretty cool new features of Visual Studio 2010 (in the Premium and Ultimate) is that they have provided you basic modeling abilities inside the IDE.  One of the new features is the Layer Diagram.  A Layer Diagram allows you to visually see how your various components (from assembly all the way down to methods) interact and relate.  One great feature that the Layer Diagram provides you is a way to be able to take a snapshot of your systems architecture and later perform validation against that snapshot to see if your code still conforms to your desired layout.

In this post we will review how to create a layer diagram and then how to validate your architecture against that diagram.

  1. Creating the Diagram…

    To create a new Layer Diagram use Architecture –> New Diagram –> Layer Diagram (you will see the dialog below)
    image 

    If you have not already created a new Modeling Project (new project type in VS) you will be asked to do so now.  If you already have one just associate this new diagram to that project.
  2. Adding Layers to the Diagram…

    Once you have created your new layer diagram it is time to start adding layers (components) to it.  You do this by opening the Architecture Explore (View –> Architecture Explorer).   When you open the explorer it should look something like below.

    image

    Now that you have the explorer open, simply drag on items from the view onto canvas as such:

    image

    Take notice that there are no association lines in the diagram above, that is because I have not added them yet.  To add them I can either do it the hard way, or the easy way.  The hard way involves me manually adding the association between each later, the easy way is by having the system do it.  I am going to choose the easy way here.  To add them automatically just right click on the canvas and click ‘Generate Dependencies’.  Doing this will allow VS to determine your current associations and set them up for you.

    image

    Once VS is done, the canvas should look like below:
    image
  3. Validating your Architecture…

    Lets pretend that some time has gone by and you want to double check to see if your code still reflects your desired architecture as you laid out previous.  To do this you simply need to open the diagram and click ‘Validate Architecture’

    image

    After clicking ‘Validate Architecture’ VS will spin through and verify your architecture.  If it is found to still be ‘valid’ you will get no errors.  If it is no longer valid you will get errors like below:

    image

    If/When you receive errors you need to determine if the original layout needs to be adjusted, or if there are indeed violations.  If there are violations you should fix them and then rerun the validation to ensure you have corrected everything. 

Now, that was pretty easy and very, very powerful.  This is one of the great new features of the IDE and I cannot wait to start using it on all my projects.

Till next time,


Posted 03-21-2010 12:45 PM by Derik Whittaker

[Advertisement]

Comments

Sanjeev Agarwal wrote Daily tech links for .net and related technologies - Mar 23-25, 2010
on 03-23-2010 2:41 AM

Daily tech links for .net and related technologies - Mar 23-25, 2010 Web Development Introducing Browsers

try wrote re: Validating Application Architecture with Visual Studio 2010 – Layer Diagrams
on 03-23-2010 8:00 AM

ty

Peter Ritchie wrote re: Validating Application Architecture with Visual Studio 2010 – Layer Diagrams
on 04-10-2010 2:11 PM

Apparently only the Ultimate edition has creation of layer diagrams and validation.  The Premium edition only has UML and Layer diagram viewers.  http://bit.ly/vs2010-matrix

Derik Whittaker wrote re: Validating Application Architecture with Visual Studio 2010 – Layer Diagrams
on 04-10-2010 2:17 PM

@Pete,

Oh, I thought I read that both Ultimate and Premium had this feature... oh well.

Peter Ritchie wrote re: Validating Application Architecture with Visual Studio 2010 – Layer Diagrams
on 04-19-2010 4:56 PM

Maybe during CTP it was available in both...

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Subscribe
Google Reader or Homepage

del.icio.us CodeBetter.com Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl CodeBetter.com Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of Devlicio.us
Red-Gate Tools For SQL and .NET

NDepend

SlickEdit
 
SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
LiteAccounting.Com
DevExpress
Fixx
NHibernate Profiler
Unfuddle
Balsamiq Mockups
Scrumy
JetBrains - ReSharper
Umbraco
NServiceBus
RavenDb
Web Sequence Diagrams
Ducksboard<-- NEW Friend!

 



Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers

 

Community Server (Commercial Edition)