Change Unidirectional Association to Bidirectional
From CSSEMediaWiki
(Difference between revisions)
m (Reverted edits by Ebybymic (Talk); changed back to last version by Brett Ward) |
|||
Line 1: | Line 1: | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
If you have two classes that need to use each other's features, but the link currently goes one way, change the association to bidirectional to allow needed navigation. | If you have two classes that need to use each other's features, but the link currently goes one way, change the association to bidirectional to allow needed navigation. | ||
Latest revision as of 03:11, 25 November 2010
If you have two classes that need to use each other's features, but the link currently goes one way, change the association to bidirectional to allow needed navigation.
This refactoring uses back pointers to implement the needed bidirectionality. This pointer will be added as a field. Decisions will also need to be made on which class controls the association, with the non-controlling side needing a helper method. The existing modifier will need to be altered or added to the controlling side to update the back pointers.
See Also: