The VSTA Layer Diagram and the p&p App Arch Guide 2.0
Join the DZone community and get the full member experience.Join For Free
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.
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.
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...
Published at DZone with permission of Clemens Reijnen. See the original article here.
Opinions expressed by DZone contributors are their own.