Monday, 11 April 2016

How to describe Association in OOPs ?


This relationship manifests itself in the exchange of messages among the instances of associated classes.
If two objects should be capable of sending messages to each other, their respective classes should share association  relationship.

 
















Association examples




One can specify roles of classes in association relationship

Role names are converted to attributes names inside the class body.
Role names are the attributes of the relationship, not the classes participating in the relationship.



Binary association

Both classes know each other.


Usually "knows about" means a pointer or reference.
Other methods possible: method argument, tables, database, ...
Implies dependency cycle



Unary Association

A knows about B, but B knows nothing about A.


Arrow shows direction of association in direction of dependency.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.