Change Unidirectional Association to Bidirectional

You have two classes that need to use each other's features, but there is only a one-way link.

Add back pointers, and change modifiers to update both sets.

image/svg+xml Order Customer 1 Order Customer 1

inverse of Change Bidirectional Association to Unidirectional


Doing a remove

In the example I showed an addOrder method, but I didn't show the removeOrder method. If you want to do a remove, you would write it like the add method but set the customer to null.

Class Customer ...
 void removeOrder( Order arg ) {
  arg.setCustomer( null );