jGuru
Register Email     Password Forgot your
password?
HOME FAQS FORUMS DOWNLOADS ARTICLES PEERSCOPE LEARN

  Search   jGuru Search Help

Question What is an association class?
Topics Process:UML
Author John Moore PREMIUM
Created Jul 12, 2000 Modified Jul 12, 2000


Answer

An association class is used to model an association as a class. Association classes often occur in many-to-one and many-to-many associations where the association itself has attributes.

As an example, consider a many-to-many association between classes Person and Company. The association could have properties; e.g., salary, jobClassification, startDate, etc. In this case, the association is more correctly modeled as an association class with attributes rather than trying to fold the attributes into one of the classes in the association.

An association class is rendered by a dashed line from the association to the class rectangle. Each link in the association is an object of the association class. An association class is essentially a class attached to an association; the association itself is modeled as a class.

Here are some pointers to consider when modeling with association classes:

  1. You can’t attach the same class to more than one association; an association class is the association.
  2. The name of the association is usually omitted since it is considered to be the same as that of the attached class.
  3. Distinguish between the use of an association class as a modeling technique and the implementation of the association class. There can be several ways to implement an association class.


Is this item helpful?  yes  no     Previous votes   Yes: 2  No: 1



Comments and alternative answers

Comment on this FAQ entry

Can someone provide an example implementation of an...
Mario L. Peralta, Aug 14, 2000
Can someone provide an example implementation of an association class?

Is this item helpful?  yes  no     Previous votes   Yes: 0  No: 0



Reply to this answer/comment  Help  
I usually implement an association class in following...
Andrei Lopatenko, Sep 4, 2000
I usually implement an association class in following way. If we have relations between Persons and Classes then I declare (in a simplest way)

interface CanBeAssociated {
  public addAssociation(Association assoc);

}

class Person implements CanBeAssociated{
  ...
  private Vector Associations;
  public addAssociation(Association assoc){
    ...
  }
}

class Class implements CanBeAssociated{
  private Vector Associations;
  public addAssociation(Association assoc){
    ...
  }
}

class cAssociation extends UML.Association {
  addSource(CanBeAssociated source) {
    ...
    source.addAssociation(this);
  }
  addTarget(CanBeAssociated target) {
    ...
    target.addAssociation(this);
  }
}

For associations I create

obj assoc = new cAssociation();
assoc.addSource(person1);
assoc.addTarget(class1);
assoc.addTarget(class2);
...

Of course this is only a sketch.

Is this item helpful?  yes  no     Previous votes   Yes: 0  No: 0



Reply to this answer/comment  Help  
Can association classes, and associations in general,...
fred rosenberg, Jan 30, 2001
Can association classes, and associations in general, be implemented in EJB?

Is this item helpful?  yes  no     Previous votes   Yes: 0  No: 0



Reply to this answer/comment  Help  


Ask A Question



 
Related Links

UML FAQ

UML Forum

IBM UML Resource Center

UML Resource Page for OMG

Object-Oriented Bibliography

Cetus Links on UML

Wish List
Features
About jGuru
Contact Us

 



The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers