🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.java
Article #376

Re: Refactoring book + one to many implementation

#376
From: Mark Fussell
Date: Fri, 12 Nov 1999 00:00
33 lines
2102 bytes

Andy Bulka wrote:
> I've just been using the "Change Unidirectional Association to
> Bidirectional" on p199 of M. Fowler's Refactoring book.
[snip]
> So anyway, turning our attention back to the ONE-to-many (which ends up not
> being so elegant, once you flesh it all out - that's my claim...)   I went
> ahead and invented/implemented the 'missing' removeOrder() method  thus: 

[minor corrections to the example method]
> class Customer ...
>  void removeOrder( Order arg ) {
>   _orders.remove( arg );
>   arg._customer = null;
> }

actually you should be able to do the above with:
    void removeOrder( Order order ) {
        order.setCustomer(null);
    }

which would keep all the association-controlling logic in the
'setCustomer' method.  Since this is a nice simple one-liner, it would
be good if it was in the book, but it was 430 pages as is :-) and he may
have thought the one-liner was apparent.

--Mark
mark.fussell@chimu.com

  i   ChiMu Corporation      Architectures for Information
 h M   info@chimu.com         Object-Oriented Information Systems
C   u    www.chimu.com         Architecture, Frameworks, and Mentoring
Technical Details
Message-ID: <382C8CEE.39347C17@chimu.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <80hvjs$1pqi$1@otis.netspace.net.au>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fbe9c,da48a4987570047e,start
X-Google-Attributes: gidfbe9c,public
X-Google-Thread: f5d71,da48a4987570047e,start
X-Google-Attributes: gidf5d71,public
X-Google-Thread: 10d6db,da48a4987570047e,start
X-Google-Attributes: gid10d6db,public
X-Google-Thread: 114809,da48a4987570047e,start
X-Google-Attributes: gid114809,public
From: Mark Fussell <mark.fussell@chimu.com>
Subject: Re: Refactoring book + one to many implementation
Date: 1999/11/12
Message-ID: <382C8CEE.39347C17@chimu.com>
X-Deja-AN: 547910708
Content-Transfer-Encoding: 7bit
References: <80hvjs$1pqi$1@otis.netspace.net.au>
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
X-Trace: nntp1.ba.best.com 942443894 216 206.86.217.25
Organization: ChiMu Corporation
MIME-Version: 1.0
Newsgroups: comp.lang.java,aus.computers.java,borland.public.jbuilder.java,comp.lang.smalltalk