I’ve been playing with the modelling features in VS 2010 to see what its capable of and I like what I’ve seen so far.
Dev10 adds a new project template called “Modelling Project” in which you can create a series of new diagrams. These diagrams include 5 of the 13 UML 2.x diagrams plus a Layer diagram and a Directed Graph diagram (.dgml).
UML Class Diagram
This works very well and seems to be an excellent tool for creating your logical model. At first you may think that this would replace the class diagram that was introduced with VS 2008, but there are some key differences. The existing class diagram (.cd) is a ‘live’ visualisation of your code. You can reverse engineer it from existing code or create code stubs from the diagram. The new UML Class Diagram (.classdiagram) has no links to your code at all, there is no reverse engineering and if you want to do code generation you will need to use T4 text templates. From what I’ve read reverse engineering is a feature that is being worked on so we will see it at some point.
UML Sequence Diagram
This is the only diagram type that does support reverse engineering and I’m very impressed with it. By right clicking on a method in your code you can select ‘Generate Sequence Diagram’ and get something like this:
You can navigate from the diagram to the code with a simple right click ‘Go to definition’.
UML Use Case Diagram
This is pretty much what you would expect for use cases – a simple drawing surface to aid the modelling of use cases. Useful and I’m glad its now a part of the VS IDE.
UML Activity Diagram
Again this is pretty much what you would expect – an activity diagram drawing surface and simple to use toolbox for adding items to it.
UML Component Diagram
As with the Use Case and Activity diagrams this is a drawing surface for constructing component diagrams. Not much else to say here: simple and better than Visio.
This diagram is intended to represent the layers of your architecture and it slightly more than just a drawing surface as it has a Layer Validation feature. By assigning code to different layers in this diagram (a drag and drop exercise) you can generate and validate the dependencies between the classes to ensure that there are no incorrect layer dependencies. I know I would have found this useful in the past when developers have incorrectly added dependencies which violated the architecture.
The Patterns and Practices team have also created a set of guide layer diagrams which you can add on with a small download. This will give you toolbox items for the following reference architectures:
- Web Application
- Rich Client Application
- Rich Internet Application
- Services Application
- Mobile Application
Directed Graph Document
Directed Graph Documents (.dgml) are used for a number of different features in VS 2010 (e.g. Dependency Graphs). It is a generic document type to represent any type of node/connection relationship. Below is a simple Namespace dependency graph
The modelling is definitely a step in the right direction and what I’ve seen has been impressive , but I cant help but feel that there some features fell below the line when it came to the release of Dev10, specifically in relation to the UML Class diagrams. That aside I’m pleased that I’ll be able to do a lot of my modelling in VS from now on.
** Update 16/07/2010 - The UML and modelling features have been enhanced by the release of "Visual Studio 2010 Visualization and Modelling Feature Pack" - read more about it here. **