Search code examples
classoopumlclass-diagramvisual-paradigm

How can I describe these types in UML class diagram?


I'm making a class diagram for a project.

How can I describe vectors, lists, files or unsigned types?

I would like to make a detailed diagram so I need to specify the types of the members and the input/output parameters of the methods.

Thank you all!


Solution

  • For more detailed description of the inner structure of the class you need a Composite Structure Diagram. There you can describe your methods as "ports". And your fields as attributes. You can show there really almost everything!

    enter image description here

    For detailed description of the specific instances of the class and their mutual behaviour you need an Object diagram.

    At the links applied you can see a bit how to make them. But take it as a start only.

    The class diagram is too common to describe the inner structure of the class. It is tooled for the description of the inter-classes relations. So, you can put your information into the model of the class, but some of it won't be seen on the diagram. But I would advise you to start from the class diagram and make it as detailed as it can show and only later go to more detailed diagrams. Maybe you won't need them after all.

    Edit:

    You can make a port on the border of your class, name it fileName and connect it to io interface you use. (Composite Structure Diagram only)

    As for vector/list, it is easier, and could be done in a Class Diagram. If you want to show that some attribute is a vector or list, simply write: someAttr:List or put a List block on the diagram, draw association to it and name its end "someAttribute". You could do it with File, too, but there you should draw more, I think, to show the used io interface.

    For showing attributes in class diagram also look here.