views:

1335

answers:

2

I have the requirement of generating UML Diagrams for one of my C++ assignments. I'm using Visio 2007 and I'm having trouble representing C++ vectors. The only way I can see this working is creating a custom C++ datatype or creating a vector class in my project, then for each instance of a vector in the UML, I need to dig into the properties and add <Class> into the suffix field.

Basically I'm trying to get vector<Object> without digging into the properties and adding <Class> to the suffix field every time.

I'm pretty much stuck with Microsoft software for making diagrams and coding so please don't suggest I use different software. However, if Visual Studio 2003 supports making UML Diagrams in a less painful way than Visio, I wouldn't object to using Visual Studio but please tell me where that option is.

+4  A: 

You don't need to stipulate that it's a vector on the UML diagram.

In the example you're giving, there is a one-to-many relationship between one class and another. That's the significant information you need to communicate.

You've chosen to implement this as a vector: this is an implementation detail that doesn't need to go on the diagram - just display a one-to-many association.

If, for some reason, you need to change this to a std::list, or a std::deque, or any other stl container, you won't need to update the diagram, because the one-to-many concept is still the same.

Remember that you are displaying an abstraction of the code. If you want to convey how all the classes conceptually relate to eachother, a UML class diagram is ideal. If somebody wants to know the details of how it's implemented, he or she can always use the diagram as a starting point before looking at the source code itself.

For an example of one-to-many relationships displayed using UML, click here

Andrew Stapleton
How would I display a one to many relationship in uml? That topic was never covered in my class. And UML isn't used as an abstraction of code in my class, every method and instance variable is to be displayed. It's basically a header file without documentation.
epochwolf
I've added a link to an example in the response.
Andrew Stapleton
By default collections in UML are sets. You should also add a `{sequence}` property string to indicate that the collection is ordered and allows duplicate elements. You can also use `{ordered}` to signify the collection is ordered, or `{bag}` to if it allows duplicate elements.
Pete Kirkham
+1  A: 

UML has a notation for parameterized classes. The parameter type goes into an overlapped box in the top right corner like this Whether your tools support it is another matter...

fizzer