posted 22 years ago
Hi Erum,
I agree with John on this.It depends on what is the actual requirement.
If you are speaking of the association between Order and OrderLineItem, you would expect the OrderLineItem to be managed by Order.The OrderLineItems is very specific to a particular Order instance, and if an Order is deleted all the corresponding OrderLineItems would be deleted.Hence, this would be a case of strong association also called composition, wherein Order would have one of its attributes as OrderLineItem (may be a Vector to hold all the lineitems).
On the other hand, consider a case of Employee and Department.The association between these two classes is not of the same type as Order and OrderLineItem.Unlike Order and OrderLineItem, you would expect the Department to exist even if a specific instance of an Employee is deleted. Most likely you would like to know which Employee works in which Department.So, we may have a method(operation) in Employee class, say inDepartment(Department dept), which return a boolean to suggest whether the present Employee instance is working in the passed Department reference.
I would like to mention, that in strict UML terms, the latter case is not a association but a dependency (shown by dotted line in Class Diagram artifact).
To sum up, it depends on what kind of associativity you are defining at the Design Level.The important thing to ask is whether you would want Object A to manage the life cycle of Object B.If yes, show that as a composition, other wise show it as a dependency.
Hope this helps,
Sandeep
SCJP2,OCSD(Oracle JDeveloper),OCED(Oracle Internet Platform)