Article View: comp.lang.java
Article #382Re: Refactoring book + one to many implementation
From: abulka
Date: Sun, 14 Nov 1999 00:00
Date: Sun, 14 Nov 1999 00:00
47 lines
2811 bytes
2811 bytes
Mark Fussell <mark.fussell@chimu.com> wrote:
> No it doesn't. Are you actually testing this out?
You are right. Martin Fowler is right. I am wrong.
What I have been doing is testing in Object Pascal and translating back
to Java - hence the little syntax errors you have been picking up.
In my tests I was using an INCORRECT version of setCustomer that was
testing the incoming argument 'arg', rather than the private _customer
field. Viz:
void setCustomer (Customer arg) {
if (arg != null) _customer.friendOrders().remove(this);
_customer = arg;
if (arg != null) _customer.friendOrders().add(this);
}
rather than the original, correct:
void setCustomer (Customer arg) {
if (_customer != null) _customer.friendOrders().remove(this);
_customer = arg;
if (_customer != null) _customer.friendOrders().add(this);
}
(All I can say in my defence is that because the Java language
distinguishes and encourages usage like "Order order _order"
and "Customer customer _customer", I need to be more careful in the
future. In object pascal I am used to TCustomer Customer fCustomer)
Anyway, now that this has been brought to my attention, and re-tested,
I now see the simple beauty of the original Fowler code. In fact, the
setCustomer algorithm is perfectly described in the Refactoring book
text p199: "first tell the other object to remove its pointer to you,
set your pointer to the new object, and then tell the new object to add
a pointer to you."
> Good luck...
Thanks for your patience and assistance,
-Andy
Sent via Deja.com http://www.deja.com/
Before you buy.
Technical Details
Message-ID:
<80ndoh$sh7$1@nnrp1.deja.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<80hvjs$1pqi$1@otis.netspace.net.au> <382C8CEE.39347C17@chimu.com> <80iicf$od1$1@nnrp1.deja.com> <382D1653.EF337931@chimu.com> <80krmj$7sp$1@nnrp1.deja.com> <382E0AD4.79C1F9C5@chimu.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f5d71,da48a4987570047e X-Google-Attributes: gidf5d71,public X-Google-Thread: fbe9c,da48a4987570047e X-Google-Attributes: gidfbe9c,public X-Google-Thread: 10d6db,da48a4987570047e X-Google-Attributes: gid10d6db,public X-Google-Thread: 114809,da48a4987570047e X-Google-Attributes: gid114809,public From: abulka@my-deja.com Subject: Re: Refactoring book + one to many implementation Date: 1999/11/14 Message-ID: <80ndoh$sh7$1@nnrp1.deja.com> X-Deja-AN: 548571368 References: <80hvjs$1pqi$1@otis.netspace.net.au> <382C8CEE.39347C17@chimu.com> <80iicf$od1$1@nnrp1.deja.com> <382D1653.EF337931@chimu.com> <80krmj$7sp$1@nnrp1.deja.com> <382E0AD4.79C1F9C5@chimu.com> X-Http-Proxy: 1.0 proxy2.netspace.net.au:8080 (Squid/2.2.STABLE3), 1.0 x35.deja.com:80 (Squid/1.1.22) for client 210.15.250.211, 203.23.72.4 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Sun Nov 14 22:40:17 1999 GMT X-MyDeja-Info: XMYDJUIDabulka Newsgroups: comp.lang.java,aus.computers.java,borland.public.jbuilder.java,comp.lang.smalltalk X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows NT)