Says Fowler (p. 57): "An association represents a permanent link between two objects. That is, the link exists during the whole lives of the objects, although the instances that are connected may change over time." There seems to be a contradiction between "whole lives" and "may change over time". Consider a Man-Woman association with a 1-1 multiplicity. Let m and w be respective instances associated via this association. Should the link between m and w exist for the whole lifetime of the objects or can the relationship become m'-w or m-w' at some point in time? Panagiotis.
Panagiotis, I believe, the "link exists during the whole lives of the objects", means the reference of the associated object would be permament. For instance, in the "Catalog" and "Product" case, if the Catalog contains a Product, there would be an attribute defined in the Catalog to hold a Product instance.This represents a permanent link between the two objects. On the other hand, the Product reference may point to different instances in the Catalog class.This means, the instances may change over time. To represent as Java code, it would be:
Hope this helps, Sandeep [This message has been edited by Desai Sandeep (edited May 20, 2001).]
posted 19 years ago
I see what you mean. It is the _reference_ that is permanent but the referred-to object may change (or even be null as Fowler says). Makes perfect sense now. Thanks Desai for clarifying this. Panagiotis.
Good point. I could also see some design patterns possibly changing the way it actually behaves. i.e. The Male object may be in the married state or single state, where you could use the state pattern to alter his behavior, for example the Male in the married state would be less friendly and more stressed ------------------ David Roberts - SCJP2,MCP
David Roberts - SCJP2,MCP
Yeah, but how did the squirrel get in there? Was it because of the tiny ad?
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop