This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Associations in OOPs

 
sreedhar Lackka
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Thanks in advance.

I am aware of different Associtaions are Composistions,Aggregation and Generalization.

Could any one please explain in simple terms about the differences and where and why we should use them in our applications.

And, How one association can be translated to Java like suppose if I want to translate composistion how it will be seen in Java.


Thanks,
Sree
 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4433
256
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please have a look at AssociationVsAggregationVsComposition
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just for clarity, Composition, Association and Aggregation are specific types of UML "relationships."

Association is a relationship between two classes.

Composition is a relationship between two classes.

Aggregation is a relationship between two classes.

 
sreedhar Lackka
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks a lot for the reply.

I was aware of these basics but could any one please let me know, with a Java code as an example.
And mostly I would like to know the difference between Composition and Generalization.

Regards,
Sree
 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4433
256
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at this topic for some examples.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An example of the UML concept of Generalization :



GeneralBook is a "Generalization" of DetailedBook. And, DetailedBook ISA GeneralBook.


An example of the UML concept of Composition *:



* When the Car is destroyed the Driver is destroyed as well. The application is designed this way.
 
sreedhar Lackka
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for your information!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic