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!
From the first look at it, I thought I saw it somewhere. Then I remembered.
It looks very much like diagrams you would find in the good old Rational Rose.
All good comes back?
@Developer Art
UML was never gone.
Hi, nice article! Do you know if there is any way to export/save the diagrams as PNG/JPEG or such?
Thanks
Hi Mickel! You can copy the diagram as image to clipboard and save it using any grpahics program. Just right click on the diagram and choose copy as image (or something like that). You can also paste the image directly to documents that support graphics pasting.
Why don’t I have this template installed? Nor can I find it online? I would really like to check this feature out but it seems it has not been installed with my VS2010!
Hi Tom!
What version of VS2010 do you have? I have VS2010 Ultimate Beta 2 installed and it contains those architecture projects too
VS2010 Professional Beta 2 don’t have UML modeling tools?
Is there any way to create a link to a diagram in a normal SharePoint folder? I could export an image and save that in SharePoint, but is there a way to create at least a warm if not a hot link?
Regarding whether UML can be used for modeling at physical level, It certainly can be. However, usability of a UML model extended by a custom profile is still worse than usability of a DSL model built specifically for that purpose. Take the database profile in this article as an example. Yes, you could model a database with it, but more than a half of the built-in attributes in UML Class diagrams are not applicable to database models, which will cause confusion and make it more difficult to use.
Thanks Gunnar for the details.
Have a question here. I installed Visualization_and_Modeling_Feature_Pack and its Runtime, but still not able to see “Modeling Projects” in the new project dialog box. I choose Modeling group but it does not list “Modeling Project”.
Please help me on how I can install Modeling project template
Thanks,
Meenakshi
Hi Meenakshi! Visualization and Modeling Feature Pack is not the same thing as modeling projects. Modeling projects are part of Visual Studio 2010 Ultimate Edition.
Nice introduction to the VS2010 UML features.
I have documented these features more fully in my e-book (soon to be a book) “UML Software Design with Visual Studio 2010”.
http://www.lotontech.com/uml
How to connect all model and complied to exe file.
I cannot understand your question well, pimsinnum. What you exactly wish to achieve?
Visual Studio does not support any programming language, resolution, or the tool itself, rather than what is used to connect to the functionality encoded as a VSPackage. Once installed, the feature is available as a service.
Regarding whether UML can be used for modeling at physical level, It certainly can be. However, usability of a UML model extended by a custom profile is still worse than usability of a DSL model built specifically for that purpose.
Than you very much, its been really usefull for me!
Pingback:Visual Studio Extension: Save UML diagram as image | Gunnar Peipman - Programming Blog