• 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

association class and link attribute

 
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Association b/w two classes A-->B may be implemented as class A holding a reference to object B, in its instance data. Where does the association class come into picture? It is mentioned that if the association has attributes, we go for an association class. If so, is link an instance of an association class? Not clear about these concepts. Can someone please explain with simple examples.
Thanks.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I may be struck by lightning for saying so, but this is very similar to relational database design when we stick attributes on an association table. Say we have people related to people - parents, children, aunts, uncles, etc. If one person has a simple collection of other people, we don't know how they are related. Maybe we make a tiny Relative object that holds a person pointer and a relationship name. Now a person can have a collection of Relatives, and we look at each object to see exactly how they are related.
Man, that example used relationship too many ways. Sorry. But it gets worse. This will be hard to model:
================

I Am My Own Grandpa
Many, many years ago
When I was twenty three
I got married to a widow
Pretty as could be.
This widow had a grown up daughter
With flowing hair of red,
My father fell in love with her
And soon the two were wed.
This made my dad my son-in-law
And changed my very life.
Now my daughter was my mother,
For she was my father's wife.
To complicate the matters worse
Although it brought me joy,
I soon became the father
Of a bouncing baby boy.
My little baby then became
A brother-in-law to dad,
And so became my uncle,
Though it made me very sad.
For if he was my uncle,
Then that also made him brother
To the widow's grown up daughter,
Who of course was my step-mother.
Father's wife then had a son
Who kept them on the run,
And he became my grandson
For he was my daughter's son.
My wife is now my mother's mother
And it makes me blue.
Because although she is my wife,
She's now my grandma too.
If my wife is my grandmother,
Then I am her grandchild.
And every time I think of it
It simply drives me wild.
For now I have become
The strangest case you ever saw,
As the husband of my grandmother,
I am my own grandpa!
Ray Stevens
[ August 23, 2003: Message edited by: Stan James ]
 
Jayadev Pulaparty
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Stan. The association relative class example clears the fog for me, but definitely not the lengthy example
 
Something must be done about this. Let's start by reading this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic