Question Feedback on class diagram

bondra

Well-known member
Joined
Oct 24, 2020
Messages
77
Programming Experience
Beginner
So this is my class diagram. Is there anything that can be improved right away?

Some questions:
1. The backing fields, should they be in camelCase or Pascal?
2. The usage of the diamond arrow seen in the picture is tricky. Is there any rule of thumb to remember? Should the diamond go to the left or right? Also, the usage of the filled diamond arrow means that Animal needs to have a petowner right?
3. Is the connection between Petowner and Ball the way to go? Or shouldn't it be a connection at all between those?
 

Attachments

  • Capture.PNG
    Capture.PNG
    59.8 KB · Views: 24
The .NET naming convention used to be that private and protected member variables be in camelCase. That was back in the .NET Framework 1.1 and 2.0 days. Since then they they just suggest it, but it really up to your teams naming conventions. Some teams still follow this old convention. Some teams put a leading underscore prefixing a camelCase member variable. Other teams use 'm_' prefix with PascalCase.

Public properties on the other hand should follow Pascal case.

The diamond represents either composition (filled) or aggregation (empty). For composition, the filled diamond is attached to the "parent" object because this is a reminder that if the parent object is destroyed, the "child" object should not exist anymore.

Recommended reading for composition vs aggregation:
 
Out of curiosity, which school are you going to and who is your teacher? They should deserve some kudos for trying to teach UML and class interface design. We don't see it that often anymore after people caught on that the Booch method and the Rational Unified Process were just ways for Booch and IBM to make more money, and didn't allow for more creative approaches to software design. (I was so disgusted with my Software Design class that was using the Booch method that I dropped the class and picked a different upper level class.)
 
Aha! It's a C# course in Sweden. I've never heard about the Booch method by name. Got some different diagrams when Googling it, but is it the cloudy variant? Or the "timeline/gant" looking thing? :)
 
Back
Top Bottom