• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

class relationships

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Suppose a class A has a 'has a' relationship with class B that can only be traversed from A to B.
In the class diagram this is shown as an arrow from A to B.
But, do I also have to show one of the following for class A:
- a property of type B (thus using the class name of B as the type)
- a property that represents the id of the related B instance (long, String)
If so, when would I use a class property and when an id property?
 
Ranch Hand
Posts: 1551
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Drawing UML diagrams is the work of artists. Different artists do it different ways. You will have some goal to motivate you to draw a class diagram. E.G. you think some class has too many responsibilities and refactoring it into two classes reduces coupling to the part of it that ... blah, blah, blah
AFAIK the arrow symbol represents a reference.
If you draw an arrow to Integer most of the time this is too fine grained.
If you draw your new class as an attribute of some class then you have deprived the rest of us on the team any idea what its attributes and operations are.
If a class is an attribute of another class, a composition relationship, then the black diamond can come into play.
UML diagrams are to communicate concepts to others. We can't read your mind and don't bore us.
If you are using a tool for engineering/reverse engineering code you'll have to follow its conventions.
HTH
 
Then YOU must do the pig's work! Read this tiny ad. READ IT!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic