Visual Studio 2010: UML modeling projects
Visual Studio 2010 introduces modeling projects that bring UML diagrams to Visual Studio. Currently it is not possible to generate classes from diagrams automatically but I don’t think it is a problem – good UML diagrams visualize different aspects of system short and clearly and they usually don’t document everything you can find in system. In this posting I will show you how to use modeling projects in Visual Studio 2010.
Creating modeling projects
Modeling projects are created as all other projects. Select New Project from menu and select Modeling Projects from templates pane. There is only one modeling project template called (very originally) Modeling Project. Select it and click Ok.
Modeling project is practically empty when it is created. On the left side of screen you should see UML Model Explorer (you can open it from View => Other Windows menu). To add new objects to UML model just right click on the title with mouse and select object type.
UML Model Explorer
You can see UML Model Explorer on image at right. I took this screenshot after adding some objects to my modeling project so you can see how this window looks like when there is some content.
You can add new objects to you model simply by right clicking on model name and selecting object type you want to add. You can define object attributes and assign values to its properties right in the UML Model Explorer.
As a next thing let’s see some example diagrams I created. There are some features I miss (like saving diagrams as image files) but diagramming works pretty fine for program in beta status. Here are my example diagrams.
Adding new diagram
New diagrams are added to model just like any other file in other projects. Just select Add new item and select item type. You can click on image below to see it at original size.
You can see in the item types list all diagrams you can add to modeling project. I am not very sure if this list is final or not because some diagram types are missing. But let’s hope the best as always.
Adding items to diagrams
After adding new diagram or opening existing ones you can add objects to diagram. You can find objects specific to diagram from toolbox. Screenshots below show you toolboxes for activity, class and user case diagrams.
Class diagram
UML class diagram shows classes in system (or subsystem) and relations between classes. Modeling projects show also attributes and methods of classes. I created simple class diagram that visualizes Party generalization and shows how this generalization can easily connect addresses to Person and Company classes.
If you have larger model that doesn’t fit to screen well you can hide members area of classes and save some more room for classes that are not visible otherwise.
Use case diagram
UML use case diagrams illustrate use cases in system (or subsystem) and actors who are related to use cases. Also relations between use cases are shown and commented if needed. My example shows simple registration process where user is identified by its digital passport and then approved by adminitrator when registration data is saved.
Activity diagram
As final example here is my activity diagram. It is simple one and it only shows you how activity diagrams look like – don’t look for any deep thoughts from this example.
There are also some good news about modeling projects. If you read Code stubbing with Visual Studio 2010 UML modeling thread from Visual Studio 2010 Beta 2 forums you can find out that modeling projects are built as easily extensible parts of projects and Microsoft is working also on code generation features. So, stay tuned – something big is happening!