개발방법론/모델링/Refactoring

Change Unidirectional Association to Bidirectional <IMG SRC = "http://www.refactoring.com/catalog/updated.gif" border=0>

아름프로 2003. 7. 29. 02:02

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.


For more information see page 197 of Refactoring

Additional Comments


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 );
}

Contributors


- Andy Bulka
- Don Roberts



***** 아름다운프로님에 의해서 게시물 복사 + 카테고리변경되었습니다 (2003-12-18 17:27)