The VSTA Layer Diagram and the P^P App Arch Guide 2.0.

Microsoft is releasing more and more tooling and guidance for the architect. With Visual Studio Team Architect 2010 Microsoft enables the architect and designer to great models which keep their value throughout the application lifecycle and with the current effort according to Architectural Guidance of the Patterns and Practices group, they are helping us making better designed applications. Combining these two efforts, knowledge and valuable models, will help the Application Lifecycle in delivering more added value to the business.   

VSTS2010 Layers



Most of the models VSTS2010 has are common used UML models, but Microsoft is also going to deliver another frequent used non-UML model, the Layer Diagram. I do think this diagram is used in all the communication of application architectures. [Cameron Skinner explains the layer diagram in more detail on his blog].

The diagram itself is very simple in notation, with only two main tools in the Layer palette, the "Layer" shape and the "Dependency" link. You can name those layers, describe allowed dependencies between those layers ( more on this later ), map your existing assets ( code, docs, what have you ) onto those layers, and validate that your architecture is conforming to the diagram.

App Arch Layers
Within the Patterns and Practices Application Architecture Guidance 2.0 the layer diagram is often used to describe, explain and communicate the overall structure for applications. In the guidance there are several common used application architectures with their pros and cons and even more important what are the constrains and decisions you have to make for the specific layers. [See part 3, chapters 9 till 13]

…discusses the overall structure for applications, in terms of the logical grouping of components into separate layers or tiers that communicate with each other and with other clients and applications. Layers are concerned with the logical division of components and functionality, and take no account of the physical location of components on different servers or in different locations.

In Part 4 Archetypes, the most common application types are discussed with layer diagrams as basis. Each archetype has their own set of layers and dependencies between those layers.

layer01 layer02 layer03 layer04 layer05 layer06 layer09 layer10 layer09 layer07

With the ‘Patterns and Practices Application Architecture Guidance’ how to use layers, how to define layers and how to structure your application together with ‘Visual Studio Team Architect 2010 Layer Diagram’ with the capability to validate, the capability to check the implementation at build-time [or any other time, See Skinners blog “Incorporate Layer Validation in your Builds” and this forum post ] there is a real benefit of using them together. Having the knowledge of the Application Architecture Guidance as a set of predefined layer diagrams available within the development environment will help development teams to make faster, consistent and validated applications.

App Arch Layers in VSTS2010
In the current VSTS2010 CTP there are already several pre-defined layers available. The Fowler Three Layer diagram, the Four Layer diagram and a MVC diagram. You can drag and drop these from the toolbar and it draws the necessary layers for you, it doesn’t add the dependencies [hopefully this will be added in the future]. Adding your own pre-defined layer diagrams to the toolbar isn’t possible [I hope they will add this functionality too] at this moment they are embedded as a binary to the resource file of the DSL, not really good for extensibility :-) . But there are more options to make your own set of pre-defined layer diagrams.

The easiest way is just draw them upfront and add one with ‘add existing item’ to your solution, not really a good way. Changing the diagram will all so change your initial version. You have to copy your initial version to the solution and add it from there to your project. Exchanging different diagrams would be hard and probably you get some problems with guid’s.

So another solution is making a template [vstemplate] of it and let it generate on the fly. With that you can use the default distribution functionality to get the template to your team members [this way, Finding and Sharing Project and Item Templates or this way How to: Publish Project Templates] and because they are created on the fly there will be no problems with guid’s

Add a new item to your solution. I’ve added a new category to ‘AppArchLayers’ to the dialog box just by adding a directory to the ../Visual Studio 10/Common7/IDE/ItemTemplates folder [for details : How to: Locate and Organize Project and Item Templates] and pasted my custom template in that directory.


As you can see this one is a test version of the template, I will rename it later on. Adding this template fires some IWizard functionality which generates the necessary layers, nested layers and dependencies.


do you like the colors :-) . This one generates the default reference architecture described in the application architecture guidance with strict dependencies. When looking at the Layer Diagram Explorer [view – other windows – Layer Diagram explorer, there is also another layer diagram window which displays the links] you can see that it uses nested layers. So, dependencies at lower level layers must have dependencies conform the top layers.


When we got this layer diagram we can start creating the projects and link them to the layers by drag and drop the projects from the Architecture Explorer.


[I also tried dragging and dropping from the solution explorer but ran in to some strange behavior, still have to log that one in the connect site].

From here developers can start doing their work, adding functionality to the different components and adding project references and now comes the really nice part, the build validates if the dependencies won’t break my model. [You also can right click on the design surface and push validate]


In this image you can see that someone [it wasn’t me] added a reference from UIComponents in the Presentation Layer to the DataHelpers component in the Data Layer and the validation error.

Making a vstemplate and the IWizard functionality just for one Archetype is a bit waste of ‘research’ time, so I also created them for all the other archetypes. [There is still the test template, have to remove that one]



This solution, of using item templates, only gives us the benefit of not having to do re-work, it captures minimal re-use of knowledge or help with defining the structure. When you read the AppArchGuid [chapter 3] there are a lot of decisions to make when defining and drawing the structure of you application architecture. See page 158. Choosing Layers for Your Application…

Use a layered approach to improve the maintainability of your application and make it easier to scale out when necessary to improve performance. Keep in mind that a layered approach adds complexity and can impact your initial development time. Be smart about adding layers, and don’t add them if you don’t need them. Use the following guidelines to help you decide on the layering requirements for your application: … see page 158

For sure you can extend the functionality of the template, put some more logic in the IWizard. Firing a real wizard with a kind of workflow which helps the user to make the decisions is a possibility. But this isn’t the best solution to capture the knowledge, the workflow, of designing the structure of your application. Microsoft Blueprints are much more sophisticated to handle this kind of ‘problems’.


A Blueprint is an accelerator for a specific type of software deliverable like a web service, a rich client, or a mobile application. A Blueprint is a package of process guidance, human-readable resources (docs, decks, videos, etc.) and machine-readable resources (code snippets, templates, frameworks, DSL tools, etc.) which help you build or manage a specific task or domain. It’s an SDK for a problem, not a product or specific technology.

Beside the sophisticated problem approach of Microsoft Blueprints it also gives better capabilities to add menuitems, see Edwards post over here about Blueprints: Custom menu filters the new fileitem menuitem only can be added to projects and actually I want it at solution item level.

So part two of this project of delivering the knowledge of the AppArchGuid to the development environment will start by making the Blueprint available for VSTS2010 and I will make another post how to create the diagrams from code later on, this year or next year...

Comments (10) -

Really cool post Laughing
Thanks ...

what a great blog, i found so many useful info here. thanks a lot.

nice blog, great layer diagram

great site..i do love this blog

Excellent post.I want to thank you for this informative read, I really appreciate sharing this great post. Keep up your work.


I know MEF for a while now, and my only problem with it is it's too messy to use it.

Well, it's easy to see it's kinda like the unity application block (with the pro's and con's) but i have to say that doing the same stuff with "unity" takes much less understanding of it and makes a much cleaner code.

Steinberg's Virtual Studio Technology (VST) is an interface for integrating software audio synthesizer and effect plugins with audio editors and hard-disk recording systems. VST and similar technologies use Digital Signal Processing to simulate traditional recording studio hardware with software. Thousands of plugins exist, both commercial and freeware, and VST is supported by a large number of audio applications. The technology can be licensed from its creator, Steinberg.

Thanks for your post, very useful and informative

Add comment

Şarkı Sozleri