wood burning stoves 2.0*
The moose likes OO, Patterns, UML and Refactoring and the fly likes Why are the relationships Association, Aggregation and Composition requried Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Why are the relationships Association, Aggregation and Composition requried" Watch "Why are the relationships Association, Aggregation and Composition requried" New topic
Author

Why are the relationships Association, Aggregation and Composition requried

ragi singh
Ranch Hand

Joined: Mar 10, 2010
Posts: 198

hi all ,

I have read on the relationships association , aggregation and composition but am unable to follow as to why they are required . Is it that we create the classes and since a particular class holds reference to another that we term the two classes to be in association relation , so what is the use of defining relationships , are we using them(relations ) to identify relationship in a particular scenario or while designing we decide our class will have relation with another class so in the diagram we declare it as an association or aggregation or composition . Please explain ....I understand their definitions and the differences between them , i want to know why were these relations designed and what are the advantages if i use the m?


Thanks and Regards.
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

These relationships are used for better OO design. And you would be most of the times using these relationships in your development.

Mohamed Sanaulla | My Blog
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4392
    
    8

The advantage is that it allows your model to more closely represent what it is you're trying to model. The different types of relationship mean slightly different things, and so using the right one gives more precise information. Which is a good thing.

Having this extra information may help you make design decisions when you get round to implementing the model. For example, deciding which classes have responsibility for creating instances of other classes.
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
These "relationships" represent ways that objects can interact with other objects. They are a fundamental part of the Unified Modeling Language (UML). However, they are not "required" for anything. but they are the only way that you can describe the "relationship" between objects and classes using the UML.

Asking why they exist is like asking why the word "the" exists in the English language. It would be extremely difficult to communicate effectively if the word "the" did not exist
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Why are the relationships Association, Aggregation and Composition requried