Patch to improve Cloneable implementation on classes which extend PGobject.

Lists: pgsql-jdbc
From: Russell Francis <rfrancis(at)ev(dot)net>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Patch to improve Cloneable implementation on classes which extend PGobject.
Date: 2007-06-24 16:52:04
Message-ID: 467EA134.6050602@ev.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

The attached patch aims to improve the current implementation of the
clone() method on classes which extend PGobject. I believe that the
current implementation has a few deficiencies, namely

1. They are implemented by calling the objects constructors which means
that each derived class must re-implement all of the logic of the parent
in order to clone itself correctly.

2. When extending an object, the default behavior of the clone() method
is to return an object of the wrong type where most developers expect
that if the derived class is Cloneable and doesn't add any mutable
fields the base classes clone() implementation should suffice in cloning
the object and it should return an object of the same type as the
derived class.

I think that this patch provides implementations of the clone() method
which falls more in line with the behavior that most developers expect
from the method. Thanks for considering the patch for inclusion in the
driver. If you have any questions or problems with it, please feel free
to ask.

Sincerely,
Russ Francis

Attachment Content-Type Size
cloneable.diff text/x-patch 8.9 KB

From: Kris Jurka <books(at)ejurka(dot)com>
To: Russell Francis <rfrancis(at)ev(dot)net>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Patch to improve Cloneable implementation on classes which extend PGobject.
Date: 2007-07-16 04:12:02
Message-ID: Pine.BSO.4.64.0707160010500.23154@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

On Sun, 24 Jun 2007, Russell Francis wrote:

> The attached patch aims to improve the current implementation of the
> clone() method on classes which extend PGobject.

Makes sense, but why are you providing clone implementations in point,
money, interval and NullObject instances? Shouldn't this already be
handled by PGObject's implementation?

Kris Jurka


From: Russell Francis <rfrancis(at)ev(dot)net>
To: Kris Jurka <books(at)ejurka(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Patch to improve Cloneable implementation on classes which extend PGobject.
Date: 2007-07-16 11:41:40
Message-ID: 469B5974.30705@ev.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Kris Jurka wrote:
>
> On Sun, 24 Jun 2007, Russell Francis wrote:
>
>> The attached patch aims to improve the current implementation of the
>> clone() method on classes which extend PGobject.
>
> Makes sense, but why are you providing clone implementations in point,
> money, interval and NullObject instances? Shouldn't this already be
> handled by PGObject's implementation?

Yes, in all of those cases the clone() implementation in PGobject would
do what is expected. I suppose I provided the method declarations and
trivial implementations for clarity but they are not needed.

Thanks,
Russ


From: Kris Jurka <books(at)ejurka(dot)com>
To: Russell Francis <rfrancis(at)ev(dot)net>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Patch to improve Cloneable implementation on classes which extend PGobject.
Date: 2007-07-16 15:03:19
Message-ID: Pine.BSO.4.64.0707161102590.32311@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

On Mon, 16 Jul 2007, Russell Francis wrote:

> Kris Jurka wrote:
>>
>> On Sun, 24 Jun 2007, Russell Francis wrote:
>>
>>> The attached patch aims to improve the current implementation of the
>>> clone() method on classes which extend PGobject.
>>
>> Makes sense, but why are you providing clone implementations in point,
>> money, interval and NullObject instances? Shouldn't this already be
>> handled by PGObject's implementation?
>
> Yes, in all of those cases the clone() implementation in PGobject would
> do what is expected. I suppose I provided the method declarations and
> trivial implementations for clarity but they are not needed.
>

OK, patch applied.

Kris Jurka