1

I have tried to get a class diagram in Visual Studio but it only shows fields and methods, and no realationship. I need to get a real UML class diagram with relationships and I can't seem to figure out how to draw one so that it corresponds with the system.

Is there someone out there who understands how to make this class and relationship diagram somewhat understandable?

123code
  • 23
  • 4
  • Welcome to StackOverflow. Thank you for taking the time to share your problem. But there is something missing from your question. Please try to better explain your issue, your development environment and the data structures, as well as to share more code (no screenshot), some samples, images or sketches of the screen, and user stories or scenario diagrams. To help you improve your requests, please read the *[How do I ask a good question](https://stackoverflow.com/help/how-to-ask)* and **Questions I avoid asking** at the top right. –  Oct 22 '19 at 10:15
  • Could you add your types def code and a screenshot of the diagram, please? –  Oct 22 '19 at 10:21
  • Hello 123code, are you satisfied with one of the answers? If yes, please check the best answer as accepted, otherwise please explain why not. – www.admiraalit.nl Nov 02 '19 at 14:42

2 Answers2

1

I recommend you to use other tools to create the UML diagrams. What is integrated in Visual studio is quite basic. You can draw them on paper / paint, or you can use more advance tools for this. This one for example https://www.draw.io/ is quite ok and i use it often.

A piece of advice? Learning about UML can help you a lot in the future. And when you start coding new projects, i advice you to draw the UML diagrams on a paper, check mentally if all is ok (the schema helps you, does all the features, what piece of code goes where etc), and only afterwards start coding.

StefanaB
  • 184
  • 2
  • 11
  • You can draw the nested classes as separate classes, and the parent ones to have one-to-many relationships to the child ones. – StefanaB Oct 24 '19 at 11:21
1

One approach is to ignore the outer class, which represents the application as a whole, and model only the three structs as classes. You draw three classes, Booking, Customer and Room, and you draw associations from Booking to Customer and to Room. These three classes probably only have attributes, no operations (in C#, structs may have methods, but this is not recommended).

If you want to model the outer class as well, you can model the structs as nested classes in the class diagram.

More information about how to model nested classes in UML: https://stackoverflow.com/a/57655130/5483079

In your case, you draw Booking, Customer and Room inside a compartment of the outer class (you didn't mention the name of this class). Then, you draw associations from Booking to Customer and to Room. The outer class acts a bit like a frame around an inner class diagram.

A third option is to model the structs as a composite structure inside a compartment of the outer class rectangle. But this is not a very common approach.

www.admiraalit.nl
  • 5,768
  • 1
  • 17
  • 32