<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Skinner's Blog : Layer Diagram</title><link>http://blogs.msdn.com/camerons/archive/tags/Layer+Diagram/default.aspx</link><description>Tags: Layer Diagram</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Custom Toolbox Items</title><link>http://blogs.msdn.com/camerons/archive/2009/10/22/custom-toolbox-items.aspx</link><pubDate>Thu, 22 Oct 2009 22:52:48 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9911739</guid><dc:creator>camerons</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/camerons/comments/9911739.aspx</comments><wfw:commentRss>http://blogs.msdn.com/camerons/commentrss.aspx?PostID=9911739</wfw:commentRss><description>&lt;p&gt;[NOTE: This post is part of a blog series, the start of which is &lt;a href="http://blogs.msdn.com/camerons/archive/2009/10/19/modeling-and-visualization-in-visual-studio-2010-ultimate.aspx"&gt;here&lt;/a&gt;.]&lt;/p&gt;  &lt;p&gt;When defining layer diagrams for your organization, or various other modeling concepts and diagrams that you want to make available to your team, you can of course simply check in those diagrams to your version control system, such as Team Foundation Server. But another mechanism we have enabled in the product that can easily be overlooked is the ability to create custom toolbox items from existing diagrams ( UML or Layer ), and then make those available through the VSIX mechanism also new in Visual Studio 2010.&lt;/p&gt;  &lt;p&gt;In this post, I’m going to walk you through the steps needed to create a couple different custom toolbox items. ( I’ll talk about the new VSIX capabilities in another post. )&lt;/p&gt;  &lt;p&gt;Let’s create a Layer Diagram ( I discuss the basics of what the Layer Diagram is about &lt;a href="http://blogs.msdn.com/camerons/archive/2009/10/20/layer-diagram-in-visual-studio-2010-ultimate-beta-2.aspx" target="_blank"&gt;here&lt;/a&gt; ) that can be used as the pattern for a new toolbox item that will appear whenever a Layer Diagram is present in the VS document well.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;1)&lt;/strong&gt; Select the “Architecture-&amp;gt;New Diagram…” menu item.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;a href="http://cwskinner.members.winisp.net/CustomToolboxItems_A3E6/image.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://cwskinner.members.winisp.net/CustomToolboxItems_A3E6/image_thumb.png" width="260" height="78" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;2)&lt;/strong&gt; Select the “Layer Diagram” in the Add New Diagram dialog, and give the diagram the “PresentationLayer” name:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://cwskinner.members.winisp.net/CustomToolboxItems_A3E6/image_3.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://cwskinner.members.winisp.net/CustomToolboxItems_A3E6/image_thumb_3.png" width="244" height="216" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;3)&lt;/strong&gt; If you are following along exactly, this will prompt you for the name of a new modeling project. Let’s give the project the name of “CustomToolBoxItems”:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://cwskinner.members.winisp.net/CustomToolboxItems_A3E6/image_4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://cwskinner.members.winisp.net/CustomToolboxItems_A3E6/image_thumb_4.png" width="244" height="170" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Cool. Now the new layer diagram and modeling project show up inside Visual Studio. &lt;/p&gt;  &lt;p&gt;What we’re going to do now is replicate a layer diagram that is found in the second edition of the &lt;a href="http://msdn.microsoft.com/en-us/library/dd673617.aspx" target="_blank"&gt;Patterns &amp;amp; Practices Architecture Guide&lt;/a&gt;. Specifically, the layer diagram described in &lt;a href="http://msdn.microsoft.com/en-us/library/ee658081.aspx" target="_blank"&gt;Chapter 6: Presentation Layer Guidelines&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;4)&lt;/strong&gt; Create the following layer diagram:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://cwskinner.members.winisp.net/CustomToolboxItems_A3E6/image_5.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://cwskinner.members.winisp.net/CustomToolboxItems_A3E6/image_thumb_5.png" width="660" height="433" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;table border="1" cellspacing="0" cellpadding="2" bgcolor="#f0ffff"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top"&gt;         &lt;p&gt;&lt;strong&gt;Tips &amp;amp; Tricks, plus a Beta2 BUG ALERT:&lt;/strong&gt;&lt;/p&gt;          &lt;p&gt;I cut a quick video to include with this post to show a couple of suggestions / tips on how to quickly build the diagram above, as well as call out some funky behavior in the Beta2 build that has since been corrected. Here’s that &lt;a href="http://cwskinner.members.winisp.net/Videos/LayerTipsTricksBug.wmv" target="_blank"&gt;video&lt;/a&gt;.&lt;/p&gt;          &lt;p&gt;One thing I failed to mention in the video is that you can navigate in and out of nested layers by holding the Shift-&amp;gt; to get the tab to go to inner layers, and Shift-&amp;lt; to go to containers.&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;strong&gt;5)&lt;/strong&gt; Save the PresentationLayer.layerdiagram&lt;/p&gt;  &lt;p&gt;At this point, you need to create a directory in your %userprofile%\my Documents\Visual Studio 2010 directory.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;6)&lt;/strong&gt; Start a command prompt and cd to %userprofile%\my Documents\Visual Studio 2010 &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;7)&lt;/strong&gt; Create a directory called “Team Architecture”&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;8)&lt;/strong&gt; cd into the “Team Architecture” directory and create another directory called “Custom Toolbox Items”&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;9)&lt;/strong&gt; Copy your “PresentationLayer.*” files from your modeling project to the “Custom Toolbox Items” directory.&lt;/p&gt;  &lt;p&gt;Here’s an image of my command line actions of steps 5-9:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://cwskinner.members.winisp.net/CustomToolboxItems_A3E6/image_6.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://cwskinner.members.winisp.net/CustomToolboxItems_A3E6/image_thumb_6.png" width="644" height="452" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Ok, we’re almost there. Before we exit Visual Studio, do take notice of the current toolbox window, which should look something like this:&lt;/p&gt;  &lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://cwskinner.members.winisp.net/CustomToolboxItems_A3E6/image_7.png" width="264" height="228" /&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;10)&lt;/strong&gt; Exit and then restart Visual Studio, and create a new modeling project.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;11)&lt;/strong&gt; Create a new layer diagram&lt;/p&gt;  &lt;p&gt;Once the new layer diagram is visible, your toolbox should look something like this:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://cwskinner.members.winisp.net/CustomToolboxItems_A3E6/image_8.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://cwskinner.members.winisp.net/CustomToolboxItems_A3E6/image_thumb_7.png" width="266" height="281" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;At this point, you can select the “PresentationLayer” toolbox item and drop into your new layer diagram. You should see the exact same diagram that we created in the step 4! &lt;/p&gt;  &lt;p&gt;Now this is great, but we also give you the ability to control how these new toolbox items are displayed and organized. Enter the .tbxinfo file.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;12)&lt;/strong&gt; Create a file called “MyCustomItems.tbxinfo” in the “Custom Toolbox Items” directory we created in step 8.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;13)&lt;/strong&gt; Open that file in Visual Studio, and paste the following code:&lt;/p&gt;  &lt;div style="border-bottom: black 1px solid; border-left: black 1px solid; width: 100%; overflow: scroll; border-top: black 1px solid; border-right: black 1px solid"&gt;&amp;lt;?xml version=&lt;span style="color: red"&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt; encoding=&lt;span style="color: red"&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt; ?&amp;gt;     &lt;br /&gt;&amp;lt;customToolboxItems xmlns=&lt;span style="color: red"&gt;&amp;quot;http://schemas.microsoft.com/visualstudio/2010/TeamArchitect/CustomToolboxItems&amp;quot;&lt;/span&gt;&amp;gt;     &lt;br /&gt;&amp;#160; &amp;lt;customToolboxItem fileName=&lt;span style="color: red"&gt;&amp;quot;PresentationLayer.layerdiagram&amp;quot;&lt;/span&gt;&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;displayName&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;value&amp;gt;Presentation Layer Pattern&amp;lt;/value&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/displayName&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;tabName&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;value&amp;gt;Patterns &amp;amp;amp; Practices&amp;lt;/value&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/tabName&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;image&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;bmp fileName=&lt;span style="color: red"&gt;&amp;quot;cloudservice.ico&amp;quot;&lt;/span&gt;/&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/image&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;f1Keyword&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;value&amp;gt;PLayerHelp&amp;lt;/value&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/f1Keyword&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;tooltip&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;value&amp;gt;Create the Presentation Layer &lt;span style="color: blue"&gt;As&lt;/span&gt; mentioned &lt;span style="color: blue"&gt;In&lt;/span&gt; Pattern &lt;span style="color: blue"&gt;And&lt;/span&gt; Practices' Architecture Guidance v2&amp;lt;/value&amp;gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/tooltip&amp;gt;     &lt;br /&gt;&amp;#160; &amp;lt;/customToolboxItem&amp;gt;     &lt;br /&gt;&amp;lt;/customToolboxItems&amp;gt; &lt;/div&gt;  &lt;div&gt;&amp;#160;&lt;/div&gt;  &lt;div&gt;Once you save that file, exit Visual Studio, open a modeling project and open a layer diagram, you’ll see the following:&lt;/div&gt;  &lt;div&gt;&amp;#160;&lt;a href="http://cwskinner.members.winisp.net/CustomToolboxItems_A3E6/image_9.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://cwskinner.members.winisp.net/CustomToolboxItems_A3E6/image_thumb_8.png" width="495" height="296" /&gt;&lt;/a&gt;&lt;/div&gt;  &lt;table border="1" cellspacing="0" cellpadding="2" bgcolor="#f0ffff"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top"&gt;         &lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt;&lt;/p&gt;          &lt;p&gt;As you play around with these custom tool box items, it is possible that you’ll start to see toolbox items from past experiments. If you start to see things your aren’t expecting, right click in the toolbox and select “Reset Toolbox”:&lt;/p&gt;          &lt;p&gt;&lt;a href="http://cwskinner.members.winisp.net/CustomToolboxItems_A3E6/image_10.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://cwskinner.members.winisp.net/CustomToolboxItems_A3E6/image_thumb_9.png" width="244" height="244" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;That’s it! You can experiment with adding more custom toolbox items created by using layer diagrams, and you can do the exact same thing with any of the UML diagrams as well. This is a great way to get started with Design Patterns or any other template you’d like to make more accessible with your engineering team.&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;  &lt;p&gt;Cameron&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;[NOTE: This post is part of a blog series, the start of which is &lt;a href="http://blogs.msdn.com/camerons/archive/2009/10/19/modeling-and-visualization-in-visual-studio-2010-ultimate.aspx"&gt;here&lt;/a&gt;.]&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9911739" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/camerons/archive/tags/tsbt-arch/default.aspx">tsbt-arch</category><category domain="http://blogs.msdn.com/camerons/archive/tags/UML/default.aspx">UML</category><category domain="http://blogs.msdn.com/camerons/archive/tags/Layer+Diagram/default.aspx">Layer Diagram</category><category domain="http://blogs.msdn.com/camerons/archive/tags/Videos/default.aspx">Videos</category><category domain="http://blogs.msdn.com/camerons/archive/tags/VS2010+Beta2/default.aspx">VS2010 Beta2</category><category domain="http://blogs.msdn.com/camerons/archive/tags/Visual+Studio+2010+Ultimate/default.aspx">Visual Studio 2010 Ultimate</category><category domain="http://blogs.msdn.com/camerons/archive/tags/VSTS+Designing/default.aspx">VSTS Designing</category></item><item><title>Incorporate Layer Validation in your Builds</title><link>http://blogs.msdn.com/camerons/archive/2008/12/11/incorporate-layer-validation-in-your-builds.aspx</link><pubDate>Thu, 11 Dec 2008 08:20:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9195002</guid><dc:creator>camerons</dc:creator><slash:comments>8</slash:comments><comments>http://blogs.msdn.com/camerons/comments/9195002.aspx</comments><wfw:commentRss>http://blogs.msdn.com/camerons/commentrss.aspx?PostID=9195002</wfw:commentRss><description>&lt;p&gt;As I promised in my &lt;a href="http://blogs.msdn.com/camerons/archive/2008/12/09/layer-validation-with-the-vsts-2010-ctp.aspx"&gt;last post&lt;/a&gt;, I want to show you how you can make Layer Validation part of your build process. I'm going to assume you've followed along from last post to make things easy. Again, this is all possible in the &lt;a href="http://blogs.msdn.com/briankel/archive/2008/10/27/helpful-links-for-the-visual-studio-2010-ctp.aspx"&gt;VSTS 2010 CTP&lt;/a&gt;.&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Unload the "Client" project ( Right click on the "Client" project and select "Unload Project" )&lt;/li&gt; &lt;li&gt;Once unloaded, right click on the unloaded "Client" project and select "Edit Client.csproj":&lt;br&gt;&lt;br&gt;&lt;a href="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/IncorporateLayerValidationinyourBuilds_11BC3/image_2.png" target="_blank"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="293" alt="image" src="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/IncorporateLayerValidationinyourBuilds_11BC3/image_thumb.png" width="342" border="0"&gt;&lt;/a&gt; &lt;/li&gt; &lt;li&gt;Find this line:&lt;br&gt;&amp;nbsp; &lt;br&gt;&lt;font color="#0080ff"&gt;&amp;lt;Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /&amp;gt;&lt;/font&gt;&lt;br&gt;&lt;br&gt;And add this line right after it:&lt;br&gt;&lt;br&gt;&lt;font color="#0080ff"&gt;&amp;lt;Import Project=" $(ProgramFiles)\Microsoft Visual Studio 10.0\Team Tools\Architecture Tools\Microsoft.VisualStudio.TeamArchitect.Validate.Targets"/&amp;gt;&lt;br&gt;&lt;br&gt;&lt;/font&gt;&lt;font color="#000000"&gt;This is a temporary step to make this work in the CTP. At RTM ( and even for Beta ), the new targets file will be part of the core MSBuild targets file.&lt;br&gt;&lt;/font&gt;&lt;/li&gt; &lt;li&gt;Save the project, then reload.&lt;/li&gt; &lt;li&gt;You'll be presented with this dialog:&lt;br&gt;&lt;br&gt;&lt;a href="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/IncorporateLayerValidationinyourBuilds_11BC3/image_12.png" target="_blank"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="449" alt="image" src="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/IncorporateLayerValidationinyourBuilds_11BC3/image_thumb_4.png" width="644" border="0"&gt;&lt;/a&gt;&amp;nbsp;&lt;br&gt;&lt;/li&gt; &lt;li&gt;Click on the "Load project normally" and click &lt;strong&gt;OK.&lt;/strong&gt;&lt;/li&gt; &lt;li&gt;Now drag the "FirstLayerDiagram.layer" file from the "Diagrams" solution folder into the "Client" project.&lt;/li&gt; &lt;li&gt;Delete the "FirstLayerDiagram.layer" file from the solution folder.&lt;/li&gt; &lt;li&gt;Select the "FirstLayerdiagram.layer" file that is now in the "Client" project, and set its "Build" action to "Validate":&lt;br&gt;&lt;br&gt;&amp;nbsp;&lt;a href="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/IncorporateLayerValidationinyourBuilds_11BC3/image_16.png" target="_blank"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="546" alt="image" src="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/IncorporateLayerValidationinyourBuilds_11BC3/image_thumb_6.png" width="369" border="0"&gt;&lt;/a&gt; &lt;br&gt;Now if you did want to leave the "FirstLayerDiagram.layer" file in the "Diagrams" solution folder, you would have to manually edit the "Client.csproj" file, changing this line:&lt;br&gt;&lt;br&gt;&lt;font color="#000080"&gt;&amp;lt;Validate Include="FirstLayerDiagram.layer" /&amp;gt;&lt;br&gt;&lt;/font&gt;&lt;br&gt;to this:&lt;br&gt;&lt;br&gt;&lt;font color="#000080"&gt;&amp;lt;Validate Include="&lt;strong&gt;..\&lt;/strong&gt;FirstLayerDiagram.layer" /&amp;gt;&lt;br&gt;&lt;br&gt;&lt;font color="#000000"&gt;You're project would look something like this ( notice the little arrow overlay, indicating that this is a reference to a file elsewhere ):&lt;br&gt;&lt;br&gt;&lt;a href="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/IncorporateLayerValidationinyourBuilds_11BC3/image_18.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="96" alt="image" src="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/IncorporateLayerValidationinyourBuilds_11BC3/image_thumb_7.png" width="244" border="0"&gt;&lt;/a&gt; &lt;/font&gt;&lt;br&gt;&lt;/font&gt;&lt;/li&gt; &lt;li&gt;Now at this point you could drop to the command line, assuming the Client.csproj file is in "c:\temp\Layer Validation\Client", and type "&lt;strong&gt;msbuild /t:ValidateArchitecture&lt;/strong&gt;".&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Ideally, it would be great to incorporate this step into the build process whenever you build the solution or Client project. You would do something like add a DependsOn="ValidateArchitecture" attribute to the "AfterBuild" target in the project file. Unfortunately, the same bug that requires you to refresh the Architectural Explorer after each build of the project will prevent this from working as it should. Clearly, this will be corrected by RTM.&lt;br&gt;&lt;/p&gt; &lt;p&gt;Hope that helps!&lt;/p&gt; &lt;p&gt;Cameron&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9195002" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/camerons/archive/tags/Layer+Diagram/default.aspx">Layer Diagram</category><category domain="http://blogs.msdn.com/camerons/archive/tags/VSTS+2010+Fall+CTP/default.aspx">VSTS 2010 Fall CTP</category></item><item><title>Layer Validation with the VSTS 2010 CTP</title><link>http://blogs.msdn.com/camerons/archive/2008/12/09/layer-validation-with-the-vsts-2010-ctp.aspx</link><pubDate>Tue, 09 Dec 2008 08:26:25 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9186397</guid><dc:creator>camerons</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/camerons/comments/9186397.aspx</comments><wfw:commentRss>http://blogs.msdn.com/camerons/commentrss.aspx?PostID=9186397</wfw:commentRss><description>&lt;p&gt;In my first post of this series, I broke down the VSTS 2010 Architecture product into "functional" areas, and I've been slowly describing the pieces. The areas highlighted ( Modeling Project &lt;a href="http://blogs.msdn.com/camerons/archive/2008/11/17/vsts-2010-architecture-part-one-model-project.aspx"&gt;here&lt;/a&gt; and &lt;a href="http://blogs.msdn.com/camerons/archive/2008/11/24/vsts-2010-architecture-part-two-model-project-and-4-1-project-template.aspx"&gt;here&lt;/a&gt;, &lt;a href="http://blogs.msdn.com/camerons/archive/2008/12/01/the-uml-model-explorer.aspx"&gt;Model Explorer&lt;/a&gt;, and &lt;a href="http://blogs.msdn.com/camerons/archive/2008/11/25/model-and-work-item-integration.aspx"&gt;Work Item Integration&lt;/a&gt; ) I've already discussed at some length. Today, I want to drill into the Layer Diagram a bit more. Specifically, I want to walk you through the steps of creating a simple Layer diagram, map your code onto it, and validate that code against the constraints authored in the diagram via a manual validation gesture. ( In a future post I'll show you how to automate validation in your build process. ) &lt;/p&gt; &lt;p&gt;For this post, I'll be using the &lt;a href="http://blogs.msdn.com/briankel/archive/2008/10/27/helpful-links-for-the-visual-studio-2010-ctp.aspx"&gt;VSTS 2010 CTP&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_4.png" target="_blank"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="480" alt="image" src="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_thumb_1.png" width="501" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&lt;u&gt;&lt;/u&gt;&lt;/p&gt; &lt;p&gt;In this example, I'm going to be using some very simplistic code, as it is not the details of the code that I'm trying to emphasize, but more the concept the code represents. Let's get started...&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Start you VSTS 2010 CTP image&lt;/li&gt; &lt;li&gt;Launch VS 2010&lt;/li&gt; &lt;li&gt;Create a C# console app called "Client", and name the solution "Layer Validation". You're "New Project" dialog should look similar to this:&lt;br&gt;&lt;br&gt;&lt;a href="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_6.png" target="_blank"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="457" alt="image" src="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_thumb_2.png" width="644" border="0"&gt;&lt;/a&gt; &lt;br&gt;&lt;/li&gt; &lt;li&gt;Now right click on the solution node, select "New Project...", select "Class Library" and name the Project "Implementation":&lt;br&gt;&lt;br&gt;&lt;a href="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_8.png" target="_blank"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="412" alt="image" src="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_thumb_3.png" width="644" border="0"&gt;&lt;/a&gt;&amp;nbsp;&lt;br&gt;&lt;/li&gt; &lt;li&gt;Do the exact same thing you just did in step 4, except name the project "Interfaces".&lt;/li&gt; &lt;li&gt;Again, do the exact same thing except name the project "Creators". You should have a solution explorer that looks similar to this:&lt;br&gt;&lt;br&gt;&amp;nbsp;&lt;a href="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_12.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="241" alt="image" src="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_thumb_5.png" width="292" border="0"&gt;&lt;/a&gt; &lt;br&gt;&lt;/li&gt; &lt;li&gt;Now expand the "Interfaces" project node. Right click on the "Class1.cs" file, select "Rename", rename the class to &lt;strong&gt;IDataRetriever.cs&lt;/strong&gt;, and click the "Yes" button when prompted. You should now see something like this in your document well and Solution Explorer:&lt;br&gt;&lt;br&gt;&lt;a href="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_14.png" target="_blank"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="297" alt="image" src="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_thumb_6.png" width="640" border="0"&gt;&lt;/a&gt; &lt;/li&gt; &lt;li&gt;Change &lt;strong&gt;IDataRetriever&lt;/strong&gt; into an interface by replacing the "class" keyword with "interface".&lt;/li&gt; &lt;li&gt;Now add a getter property that returns an object that implements the "IData" interface. You'll notice that VS is indicating to you that IData doesn't exist yet by putting the red squiggles underneath "IData":&lt;br&gt;&lt;br&gt;&lt;a href="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_16.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="71" alt="image" src="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_thumb_7.png" width="251" border="0"&gt;&lt;/a&gt; &lt;br&gt;Let's resolve this error by taking advantage of a new feature in VS 2010.&lt;/li&gt; &lt;li&gt;Right click on the offending "IData", select "Generate", and select "Other...":&lt;br&gt;&lt;br&gt;&amp;nbsp;&lt;a href="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_20.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="235" alt="image" src="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_thumb_9.png" width="404" border="0"&gt;&lt;/a&gt; &lt;br&gt;&lt;/li&gt; &lt;li&gt;You'll now be presented with the "New Type" dialog. Change the "Type Kind:" drop-down to "interface" and the "Access:" drop-down to "public". Leave the rest as defaults:&lt;br&gt;&lt;br&gt;&amp;nbsp;&lt;a href="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_33.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="234" alt="image" src="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_thumb_14.png" width="244" border="0"&gt;&lt;/a&gt; &lt;br&gt;&lt;br&gt;VS will automatically create a new interface called "IData" in a new file called "IData.cs" placed in the Interfaces project. Nice, that's exactly what we wanted! Now let's go implement the IDataRetriever interface over in the "Implementation" project.&lt;br&gt;&lt;/li&gt; &lt;li&gt;Expand the "Implementation" project node.&lt;/li&gt; &lt;li&gt;Right click on the "References" node, select "Add Reference...", click the "Projects" tab, and select "Interfaces":&lt;br&gt;&lt;br&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="412" alt="image" src="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_25.png" width="485" border="0"&gt;&amp;nbsp;&lt;br&gt;&lt;/li&gt; &lt;li&gt;Collapse the "References" node.&lt;/li&gt; &lt;li&gt;Right click on the "Class1.cs" file, select "Rename", change the file name to "&lt;strong&gt;DataRetriever.cs"&lt;/strong&gt;, and select "Yes" in the dialog that pops up. &lt;/li&gt; &lt;li&gt;Double-click on the "DataRetriever.cs" file, and make the new class implement the "IDataRetriever" interface. You'll notice that as you attempt to type "IDataRetriever", you get no intellisense support. That's ok, finish typing in "IDataRetriever", and again notice the red squigglies below the term.&lt;/li&gt; &lt;li&gt;Hover over "IDataRetriever" and notice a small rectangle under the start of the word. Click on that and select "using interfaces;". This will automatically insert the using statement that is required.&lt;br&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="189" alt="image" src="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_28.png" width="476" border="0"&gt; &lt;br&gt;&lt;/li&gt; &lt;li&gt;Now that the "using Interfaces;" line has been automatically added, select the "smart tag" again, but this time select "Implement interface 'IDataRetriever'":&lt;br&gt;&lt;br&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="165" alt="image" src="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_31.png" width="525" border="0"&gt;&amp;nbsp;&lt;br&gt;&lt;br&gt;Your final "DataRetriever" file should look like this:&lt;br&gt;&lt;br&gt;&amp;nbsp;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="365" alt="image" src="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_38.png" width="576" border="0"&gt; &lt;br&gt;&lt;/li&gt; &lt;li&gt;Now add a reference to the "Implementation" project as well as the "Interfaces" project, following the similar steps in step 13 above.&lt;/li&gt; &lt;li&gt;Expand the "Client" project node and double click on "Program.cs".&lt;/li&gt; &lt;li&gt;Type "DataRetriever", select the smart-tag and select "using Implementation;". That will automatically generate the using statement needed to use the DataRetriever type. Finish like so, adding the "using Interfaces;" statement as well:&lt;br&gt;&lt;br&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="384" alt="image" src="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_41.png" width="506" border="0"&gt; &lt;/li&gt; &lt;li&gt;Rebuild the solution. If all went according to plan, no errors.&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;So what does this program do at this point? Well, actually nothing except instantiate a type, call a property on that type, throw a "NotImplementedException", then exit. Not that interesting, but also not the point. This is just setting the stage for a very common problem found in systems of all types.&lt;/p&gt; &lt;p&gt;This code is pretty typical of code that is early in its evolutionary path. We've got a client program accessing the specific implementation of an interface directly. This is fine for now, as all the program needs is the data that "DataRetriever" was designed to retrieve ( imagine DataRetriever pulling from a SQL database for instance ). But what about tomorrow when a requirement hits your desk, demanding data to be pulled from a different data source without changing the behavior of the rest of the application?&lt;/p&gt; &lt;p&gt;What we need is to *not* make any assumptions on *how* an interface is implemented, and depend *only* on the contract of the interface(s) itself. Again, a fairly common design pattern, but one that is pretty easy to violate in today's world, as it takes but one line of code to break this pattern and create dependencies that were not intended. This is what various &lt;a href="http://en.wikipedia.org/wiki/Inversion_of_control"&gt;IoC&lt;/a&gt; containers are out to help mitigate.&lt;/p&gt; &lt;p&gt;So how do we enforce this design in our code, protecting the intent of that design, and ensure our code is resilient to this type of breakage? Enter the Layer Diagram and Layer Validation.&lt;/p&gt; &lt;p&gt;Let's create a Layer Diagram where we will visually describe the constraints on our architecture that we want to maintain.&lt;/p&gt; &lt;h3&gt;&lt;u&gt;Create the Layer Diagram&lt;/u&gt;&lt;/h3&gt; &lt;ol&gt; &lt;li&gt;Right click on the solution node and select Add-&amp;gt;New Solution Folder. Name the folder "Diagrams"&lt;/li&gt; &lt;li&gt;Right click on the "Diagrams" solution folder and select Add-&amp;gt;New Item..., select the "Layer Diagram" template, and name the diagram "FirstLayerDiagram.layer":&lt;br&gt;&lt;br&gt;&lt;a href="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_43.png" target="_blank"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="388" alt="image" src="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_thumb_18.png" width="644" border="0"&gt;&lt;/a&gt; &lt;br&gt;&lt;/li&gt; &lt;li&gt;Since these are CTP bits, there are still a few things not quite right. One of these things is the fact that you'll see two Layer Diagram Explorers appear next to your Solution Explorer. Close the one that looks like this:&lt;br&gt;&lt;br&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="161" alt="image" src="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_46.png" width="256" border="0"&gt; &lt;br&gt;&lt;/li&gt; &lt;li&gt;Now let's draw the layer diagram, make your diagram look like this one:&lt;br&gt;&lt;br&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="471" alt="image" src="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_49.png" width="319" border="0"&gt; &lt;br&gt;Please make sure that the links are going in the direction you see above, or things aren't going to work right in later steps!&lt;br&gt;&lt;br&gt;What we're saying through this diagram is that we have a "Client Logic" layer that is dependent on the "Interfaces" layer, and an "Implementation" layer also dependent on the "Interfaces" layer. What we are also saying is that the "Client Logic" layer is *not* dependent on the "Implementation" layer, nor should it be. The lack of a directed link in this last case is very important.&lt;br&gt;&lt;br&gt;But now we need to map our source code onto this layer diagram, so that the system can verify that your code is complying or *not* complying with the constraints this seemingly simple diagram is describing.&lt;br&gt;&lt;br&gt;Let's do that now.&lt;br&gt;&lt;/li&gt;&lt;/ol&gt; &lt;h3&gt;&lt;u&gt;Map Source Onto the Layers&lt;/u&gt;&lt;/h3&gt; &lt;ol&gt; &lt;li&gt;In the Solution Explorer, click and drag the "Client" project out onto the layer diagram and release your mouse on the "Client Logic" layer shape:&lt;br&gt;&lt;br&gt;&lt;a href="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_51.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="227" alt="image" src="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_thumb_21.png" width="541" border="0"&gt;&lt;/a&gt;&amp;nbsp;&lt;br&gt;&lt;/li&gt; &lt;li&gt;Drag the "Interfaces" project from the Solution Explorer out onto the layer diagram and let go over the top of the "Interfaces" layer shape:&lt;br&gt;&lt;br&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="224" alt="image" src="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_54.png" width="537" border="0"&gt; &lt;br&gt;&lt;/li&gt; &lt;li&gt;And finally, drag the "Implementation" project from the Solution Explorer out onto the "Implementation" layer shape:&lt;br&gt;&lt;br&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="187" alt="image" src="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_57.png" width="497" border="0"&gt; &lt;br&gt;&lt;/li&gt; &lt;li&gt;Your layer diagram should now look something like this. Notice the little icons in the upper right hand corner of the shapes. This indicates that source ( or some type of artifact(s) ) has been associated to the layer:&lt;br&gt;&lt;br&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="465" alt="image" src="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_60.png" width="335" border="0"&gt; &lt;br&gt;&lt;br&gt;If you select the "Client Logic" shape, then click on the "Layer Explorer", that shows you the types of items associated with the layer. In this case, the "Client" csharp project:&lt;br&gt;&lt;br&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="195" alt="image" src="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_63.png" width="733" border="0"&gt;&lt;br&gt;&lt;br&gt; Now we're ready to "Validate" our code against the diagram.&lt;br&gt;&lt;/li&gt; &lt;li&gt;Right click anywhere in the layer diagram and select "Validate":&lt;br&gt;&lt;br&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="444" alt="image" src="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_66.png" width="310" border="0"&gt; &lt;br&gt;&lt;br&gt;Notice an error is displayed in the Error Window:&lt;br&gt;&lt;br&gt;&lt;a href="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_68.png" target="_blank"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="172" alt="image" src="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_thumb_27.png" width="644" border="0"&gt;&lt;/a&gt; &lt;br&gt;&lt;br&gt;This is expected at this point, 'cause the code in Program.cs found in the "Client" project is directly manipulating types from the "Implementation" project. We just finished creating a layer diagram that declares this type of dependency invalid!&lt;br&gt;&lt;br&gt;So let's fix the problem in code so that this layer validation error goes away.&lt;br&gt;&lt;/li&gt;&lt;/ol&gt; &lt;h3&gt;&lt;u&gt;Fix Code&lt;/u&gt;&lt;/h3&gt; &lt;p&gt;Back in Program.cs, we need to make sure that we are only using types out of the "Interfaces" project, or more importantly, *not* use types out of the "Implementation" project. That's all well and good, but we need a way to get an instance of an object that implements IDataRetriever without taking a direct dependency on that type. &lt;br&gt;&lt;br&gt;Enter the Factory pattern.&lt;br&gt;&lt;/p&gt; &lt;ol&gt; &lt;li&gt;In the Solution Explorer, expand the "Creators" project, right click on "Class1.cs", select "Rename...", and rename the file to "TypeCreator.cs".&lt;/li&gt; &lt;li&gt;Add the "Implementation" project and "Interfaces" as a references to the "Creators" project ( i.e., "Creators" now depends on the "Implementation" and "Interfaces" projects ).&lt;/li&gt; &lt;li&gt;Double click on the "TypeCreator.cs" file in Solution Explorer, which will make that file fill the document well.&lt;/li&gt; &lt;li&gt;Add a static method that creates a "DataRetriever" object but returns an IDataRetriever interface. TypeCreator.cs should look similar to this:&lt;br&gt;&lt;br&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="356" alt="image" src="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_74.png" width="543" border="0"&gt; &lt;br&gt;&lt;/li&gt; &lt;li&gt;In the "Client" project, remove the "Implementation" project reference, and add a reference to the "Creators" project.&lt;/li&gt; &lt;li&gt;Change Program.cs to take advantage of the new method we just created. Program.cs should look something like this:&lt;br&gt;&lt;br&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="393" alt="image" src="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_73.png" width="612" border="0"&gt; &lt;br&gt;&lt;/li&gt; &lt;li&gt;Rebuild the solution. No errors.&lt;br&gt;&lt;br&gt;Now we need to bring up the Architecture Explorer and click the refresh button to work around a current limitation in the CTP bits.&lt;br&gt;&lt;/li&gt; &lt;li&gt;From the main menu bar, select "View-&amp;gt;Architecture Explorer".&lt;/li&gt; &lt;li&gt;Select the "Refresh Content" button on that explorer:&lt;br&gt;&lt;br&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="206" alt="image" src="http://blogs.msdn.com/blogfiles/camerons/WindowsLiveWriter/LayerValidationwiththeVSTS2010CTP_ED27/image_77.png" width="363" border="0"&gt; &lt;/li&gt; &lt;li&gt;Now bring the FirstLayerDiagram back into view, right click on "Validate", and take a look at the error tool window. No errors! WooHoo! :)&lt;/li&gt;&lt;/ol&gt; &lt;h3&gt;&lt;u&gt;Summary&lt;/u&gt;&lt;/h3&gt; &lt;p&gt;I've shown you, through an admittedly trivial example, how to validate your solution through a simple Layer diagram. I've shown you how to map source onto the layers and how to tell the system what dependencies are valid and which are not via a manual gesture and that diagram.&lt;/p&gt; &lt;p&gt;There is much more to show on this diagram and how you can interact with it. A very important next step is to show you how to make the Validation action an automatic step in your build process. I'll do that in a future post. &lt;/p&gt; &lt;p&gt;Stay tuned! :)&lt;/p&gt; &lt;p&gt;Cameron&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9186397" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/camerons/archive/tags/tsbt-arch/default.aspx">tsbt-arch</category><category domain="http://blogs.msdn.com/camerons/archive/tags/Architecture+Edition/default.aspx">Architecture Edition</category><category domain="http://blogs.msdn.com/camerons/archive/tags/Layer+Diagram/default.aspx">Layer Diagram</category><category domain="http://blogs.msdn.com/camerons/archive/tags/VSTS+2010+Fall+CTP/default.aspx">VSTS 2010 Fall CTP</category></item><item><title>Architectural Validation and Synchronization</title><link>http://blogs.msdn.com/camerons/archive/2008/09/30/architectural-validation-and-synchronization.aspx</link><pubDate>Tue, 30 Sep 2008 23:20:22 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8970675</guid><dc:creator>camerons</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/camerons/comments/8970675.aspx</comments><wfw:commentRss>http://blogs.msdn.com/camerons/commentrss.aspx?PostID=8970675</wfw:commentRss><description>&lt;p&gt;In one of the articles that just hit recently around our upcoming "Architectural Validation" feature in VSTS 2010 Team Architect, there was concern around how to "maintain all those diagrams" in context of the Architectural Validation or Layer Diagram feature. I wanted to shed a bit more light on how the association between your code and the diagram is made and maintained. We have not really discussed this nearly as much as we should, other than a quick "Map your physical assets..." comment I made in step five of &lt;a href="http://blogs.msdn.com/camerons/archive/2008/07/11/layer-diagram.aspx"&gt;this post&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Basically, I want to point out that the risk of the Layer Diagram and your source getting out of synch really depends on how you choose to use the tool.&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Association with artifacts can occur in the following ways&lt;/li&gt; &lt;ol&gt; &lt;li&gt;Link to a single artifact e.g. a class&lt;/li&gt; &lt;ol&gt; &lt;li&gt;Out of sync risk = medium high&lt;/li&gt; &lt;li&gt;Depending on the number of deletes and renames, layers linked to classes can have stale links. However, these are shown as warnings and can be cleaned up quite easily.&lt;/li&gt;&lt;/ol&gt; &lt;li&gt;Link to a group of artifacts using a container e.g. namespace&lt;/li&gt; &lt;ol&gt; &lt;li&gt;Out of sync risk = low&lt;/li&gt; &lt;li&gt;Linking a layer to a namespace indirectly links the layer to all classes in the namespace. Validation will start at the namespace and process everything in it. This indirect link allows the validation to adjust to changes to individual classes rather well.&lt;/li&gt; &lt;li&gt;Namespaces themselves do not change as often.&lt;/li&gt;&lt;/ol&gt; &lt;li&gt;Link to a group of artifacts using a query&lt;/li&gt; &lt;ol&gt; &lt;li&gt;Out of sync risk = very low&lt;/li&gt; &lt;li&gt;A query links to dynamic collection of artifacts. The query is evaluated every time you validate. Hence, like the namespace example above, changes to the results of the query are automatically factored in.&lt;/li&gt;&lt;/ol&gt;&lt;/ol&gt; &lt;li&gt;Build time validation&lt;/li&gt; &lt;ol&gt; &lt;li&gt;The integration with builds and check ins make this feature a lot more useful and bring it to the forefront of the development process. This also has the side benefit of forcing updates if they’re required.&lt;/li&gt;&lt;/ol&gt;&lt;/ol&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8970675" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/camerons/archive/tags/tsbt-arch/default.aspx">tsbt-arch</category><category domain="http://blogs.msdn.com/camerons/archive/tags/Architecture+Edition/default.aspx">Architecture Edition</category><category domain="http://blogs.msdn.com/camerons/archive/tags/Layer+Diagram/default.aspx">Layer Diagram</category></item><item><title>Layer Diagram</title><link>http://blogs.msdn.com/camerons/archive/2008/07/11/layer-diagram.aspx</link><pubDate>Fri, 11 Jul 2008 18:51:22 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8721538</guid><dc:creator>camerons</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/camerons/comments/8721538.aspx</comments><wfw:commentRss>http://blogs.msdn.com/camerons/commentrss.aspx?PostID=8721538</wfw:commentRss><description>&lt;p&gt;At TechEd2008 this year, the Rosario April CTP version of the VSTS Architecture Edition bits were demo'd during BillG's keynote by Brian Harry. Brian demonstrated the Architecture Explorer and the Layer Diagram. The Architecture Explorer is part of the April CTP, but the Layer Diagram did not make that CTP. I've received so many questions about that designer that I wanted to elaborate on the features of the diagram that you saw in the keynote, and describe the problem that diagram is out to help solve.  &lt;p&gt;The Layer Diagram is designed to allow you to specify the various layers that make up your system's architecture. It is a way to describe what you believe your architecture is, and then provides you a way of discovering what it really is. :)  &lt;p&gt;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.  &lt;p&gt;Here's a very simple layer diagram that shows a typical system with a UI or Presentation, Business or Domain Logic, Data, and Logging layer:  &lt;p&gt;&lt;a href="http://www.cwskinner.members.winisp.net/BlogImages/LayerDiagram_7C82/SimpleLayerDiagram.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="500" alt="SimpleLayerDiagram" src="http://www.cwskinner.members.winisp.net/BlogImages/LayerDiagram_7C82/SimpleLayerDiagram_thumb.png" width="540" border="0"&gt;&lt;/a&gt;  &lt;p&gt;Here is that same diagram "annotated" a bit, to describe some of the capabilities in the diagram:  &lt;p&gt;&lt;a href="http://www.cwskinner.members.winisp.net/BlogImages/LayerDiagram_7C82/LayerDiagram.png" target="_blank"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="454" alt="LayerDiagram" src="http://www.cwskinner.members.winisp.net/BlogImages/LayerDiagram_7C82/LayerDiagram_thumb.png" width="660" border="0"&gt;&lt;/a&gt;  &lt;p&gt;There are a number of ways you can approach this diagram, below is one:  &lt;p&gt;1. Create a new Layer diagram from scratch  &lt;p&gt;2. Draw the various Layer shapes and name them appropriately  &lt;p&gt;3. Use the Dependency connector to indicate the direction of allowed dependencies. As I mentioned in the annotated image, the lack of dependency links is also meaningful, in that you are indicating to the system that dependencies between two layers is not allowed.  &lt;p&gt;4. Specify additional constraints per layer that you would like to see enforced. As an example, you will be able to indicate on a per layer basis what namespaces are allowed in that layer, and which are not allowed.  &lt;p&gt;5. Map your physical assets to your specified layers. You map your assets ( code, documentation, entire projects or solutions ) via drag &amp;amp; drop from the Architectural Explorer and Solution Explorer. ( Later in the cycle, there will be more capabilities added around this step. )  &lt;p&gt;6. Validate your architecture  &lt;p&gt;This last step is where things get interesting. Steps 1-5 were all about specifying what you believe your architecture is and should be. Step 6 is all about telling you what it is.  &lt;p&gt;But when does validation occur, and what do violations look like?  &lt;p&gt;Validation can be done via a simple context menu gesture ( right click on the diagram and select "Validate" ), or as part of a check in policy, and as part of your build. The product will examine your Layer diagram ( you can have many by the way ), discover what assets are mapped and what constraints are being specified, and then analyze those assets with those constraints in mind.  &lt;p&gt;A violation ( currently ), shows up in the Error window.  &lt;p&gt;This should give you a better idea of what this diagram is all about, and you'll be able to take it for a test drive in our next CTP this fall.  &lt;p&gt;Cheers,  &lt;p&gt;Cameron&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8721538" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/camerons/archive/tags/tsbt-arch/default.aspx">tsbt-arch</category><category domain="http://blogs.msdn.com/camerons/archive/tags/Architecture+Edition/default.aspx">Architecture Edition</category><category domain="http://blogs.msdn.com/camerons/archive/tags/Layer+Diagram/default.aspx">Layer Diagram</category></item></channel></rss>