I really like the idea of having an embedded Class Designer in Visual Studio. It’s unfortunate that I can’t really use it effectively, though. I’ve been trying to use it every since it came out, but I often end up either going to Visio or just going to the whiteboard and drawing sketches manually.
There are just a few things I like about the VS Class Designer:
- It looks fancy;
- I don’t have to go anywhere else for a diagram.
As far as creating classes and its members, I think it’s much more productive to just do that in code (which is a lot faster if you’re using a tool such as CodeRush). So I really don’t see myself using the class diagram when I’m creating this stuff. If I’m trying to design something, I’ll just do it directly in a TDD style, or go to a whiteboard and sketch the simplest diagram I need in order to better understand what tests I need to write for my design.
There are more things I don’t like about the VS Class Designer:
- Even though some people like the idea that the diagram gets updated from source code, I’m not sure that’s a good thing. Most often than not, I create diagrams that are as simple as possible, where I only include as many details needed to make the intent of the design as clear as possible. That means I carefully choose what members of a class I want to display.
That said, I don’t want to add a property to a class in code and have it automatically added to the diagram (I may have added the property for implementation details and don’t want that cluttering the diagram). If it takes a lot of time from me to lay out a diagram, I may not want to add a property to a class and take the risk of that change messing up the layout of my pretty diagram. Well, that sucks (I want to make changes freely, and only change the diagram if I feel that the change is necessary to better explain the design).
- Even though not directly related to the Class Diagram, I don’t like the fact that there’s no Sequence Diagram and State Diagram designers (two of the diagrams that are really helpful in explaining designs). I do understand that the diagrams in VS are not UML diagrams, but they do have lots of similarities, and it’d be good to have something like Sequence and State diagrams available.
Now to the thing that I hate the most about it:
- There is no easy way to represent class relationships other than inheritance.
Granted, inheritance is one of the pillars of OOP and must definitely be used wherever it makes sense. However, there are other things that may be deemed more appropriate to certain designs, such as the OOD principle "favor composition over inheritance". There’s just no way to represent composition in a way that makes sense. There’s a Power Tool for VS that adds a little support for composition, but that doesn’t work for me. If you add a composition relationship between two classes, the tool adds the arrow to the diagram pointing the two classes, but doesn’t show the reference as a property on the containing class. When you do that, it also adds code to your class that you may not want. For instance, if I have a class that has a property of a type that’s another class sitting there on the same diagram, the tool isn’t smart enough to draw the arrow for you, and if you try it yourself, it’ll add another property to hold the reference. Ouch.
- There’s also no way to indicate that "this class uses that other class". One can add a "comment" to the diagram, but can’t really link it to any element on the diagram.
To overcome these problems I end up creating a part of the diagram in VS, and then using a tool such as MSPaint or Paint.NET to draw the other visual elements. What a shame.
Those are real deal breakers for me. Like I said, I keep trying to use the VS Class Diagram, but it’s been frustrating. Diagrams are useful in some areas, but I certainly don’t want to become a slave for them, and when I do want to create a diagram, I want it to be ease to create and understand, and the current tool does not really give me that.