Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 556
  • Last Modified:

Association Classes in java

What are the association classes. What, how, why, when, where we use them. What are advantages, disadvantages, practical uses of them. How we represent them in UML

please advise
Any links resources ideas highly appreciated. Thanks in advance
0
gudii9
Asked:
gudii9
  • 3
  • 2
1 Solution
 
Angelp1ayCommented:
Association classes in the UML world are essentially classes that define some logic about a relationship.

Example taken from http://www.agilemodeling.com/style/classDiagram.htm
An association class describing the relation between student and course
You could model them in-line splitting the relation to instead form 2 relations (source > association class and association class to target, in this case student > enrollment and enrollment > course). Typically they exist because the concept of a relation with meta data is a better description of the logic than 3 classes and 2 relations i.e. the student is enrolled in a class and that enrollment occurred at a certain time, rather than students have enrollments, enrollments have classes which is perhaps less obvious. UML after all is a language for describing logic and sharing that description with others.
0
 
Angelp1ayCommented:
Association classes cannot really exist in Java - you are forced to define all 3 classes and 2 relations with the enrollment type in the middle.

In some senses this is why UML exists - it explains the true semantics even if the implementation makes some sacrifices.
0
 
gudii9Author Commented:
Association classes cannot really exist in Java - you are forced to define all 3 classes and 2 relations with the enrollment type in the middle.

In some senses this is why UML exist


You could model them in-line splitting the relation to instead form 2 relations


relation with meta data is a better description of the logic than 3 classes and 2 relations

I am still not very clear on above points.

Why java does not have but UML has them. what compromise we are making. Please advise
0
 
Angelp1ayCommented:
Very generally UML is for describing the logic of a system for the purpose of communicating that logic to other people and Java is for describing a specific code implementation of that logic in a manner a computer can interpret.

UML is often used to describe semantics - the true meaning of something, whereas a real world implementation makes certain assumptions to simplify the code. Java is a simpler language to use without adding the complication of association classes. Functionally the same can be achieved in Java without them. To a person however the UML description including association classes is richer.

It's a little like how in human language we have many words describing very similar concepts because one word may have a subtle implication that helps people more rapidly understand the exact context being described. In programming however we have a very small vocabulary to avoid any ambiguity when communicating with the computer running the code.
0
 
gudii9Author Commented:
You could model them in-line splitting the relation to instead form 2 relations (source > association class and association class to target, in this case student > enrollment and enrollment > course). Typically they exist because the concept of a relation with meta data is a better description of the logic than 3 classes and 2 relations i.e. the student is enrolled in a class and that enrollment occurred at a certain time, rather than students have enrollments, enrollments have classes which is perhaps less obvious.

can you please elaborate on above. I am not able to clearly understand it. Are you referring in UML context or java context?
In java where does (which class student/course out of two classes) the enrollment drop create etc represented
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now