Tuesday, January 31, 2012

Get the Gang of Four in your Visual Studio... At least as UML Toolbox items...

Microsoft Visual Studio UK Team - Visual Studio 2010 UML Design Pattern Toolbox Items Extension

"I presented at the Black Marble Architecture Forum in the North event in December and one of the things I showed was how to create a toolbox item extension to add a UML design pattern into Visual Studio’s UML toolbox. Having done this I checked and couldn’t find any extensions that covered the Gang of Four design patterns, so I thought I’d create an extension to do just that. Let’s start at the end with where to download them and what they give you…

What do you get?

The toolbox items extension gives you some extra toolbox items that cover the majority of the core Gang of Four design patterns. Once installed, if you open a UML class diagram you should see the following additions under Structural, Creational and Behavioural (yes, British spelling) Patterns:


Then open or create a UML modeling project and once you have a class diagram you should see the new toolbox items.


I’ve added the Visual Studio solutions that I created this extension from to Codeplex here. You can download the solutions, take a look at the projects and update/improve/extend/adapt the toolbox items to suit your needs.

How do you build this?

Take a look at the Codeplex project if you want to download the full solutions but as an overview this is essentially simple. It breaks down into 4 key aspects:

UML Profile

I wanted to create a UML profile in order to define the stereotypes that I would use in the design patterns. As an example I wanted to have <<Singleton>> stereotype so that any class that you wanted to implement the Singleton pattern could be identified as such without having to rely on naming conventions, and the name can be independent of the stereotype. A secondary reason is that if I wanted to generate code from the design patterns this would allow the T4 templates to generate the appropriate code for the specified stereotype. I haven’t got round to this part but using a profile means that this will be possible in the future.

The documentation on creating a custom profile is here. This is what I followed but a summary is:



Why is this cool? Because not only do we get a pretty cool package of UML toolbox items, but we get the source AND a walkthrough for how they were created! That's cool...

NOTE: If I remember right, you'll need Visual Studio 2010 Ultimate to use these (since UML projects can only be created/authored/edited in that SKU)

No comments: