You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Thomas Neidhart <th...@gmail.com> on 2013/05/13 20:06:20 UTC

[collections] Fix Bag interface

Hi,

currently, the Bag interface states that it violates the Collection
contract. This is mainly because the interface was defined like that,
but could be easily changed.

As we are not binary compatible anymore with previous releases, it would
be the right time to do this now (or leave it as it is till the end of
time).

Any opinions / objections on this?

Thomas

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [collections] Fix Bag interface

Posted by Thomas Neidhart <th...@gmail.com>.
On 05/13/2013 08:06 PM, Thomas Neidhart wrote:
> Hi,
> 
> currently, the Bag interface states that it violates the Collection
> contract. This is mainly because the interface was defined like that,
> but could be easily changed.
> 
> As we are not binary compatible anymore with previous releases, it would
> be the right time to do this now (or leave it as it is till the end of
> time).
> 
> Any opinions / objections on this?

Ok,

I needed some time to digest the feedback.

The result of playing around with an adapter from the Bag interface to a
newly proposed Multiset is attached to COLLECTIONS-468.

The Multiset interface would be exactly the same as Bag, with the
difference that it conforms to the Collection super-interface (Multiset
deliberately does not extend Bag).

The rest of the classes in the bag package could be migrated to a new
multiset package, basically providing the same functionality.

Additionally, there would be a MultisetUtils.asMultiset(Bag) method
which wraps a Bag as a Multiset (in case there is a need for something
like that).

This would give the users the choice, and we can later on still decide
if we remove the Bag interface after all.

I am not in favor of code duplication, but I see the benefit of both
interfaces. The adapter alone would limit the use of a Multiset, as the
unmodifiable, transformed and synchronized decorators would have to be
duplicated anyway.

Thomas

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [collections] Fix Bag interface

Posted by sebb <se...@gmail.com>.
On 14 May 2013 22:37, Benedikt Ritter <br...@apache.org> wrote:
> +1
>
> since the package name will change, client code has to be changed anyway.
> Now is the time to get rid of all flaws of the old API.

+0

I agree, but the previous behaviour does seem useful.
So if it can be provided in addition to supporting the standard
Collections interface, that seems the best way forward.

>
> 2013/5/14 Matt Benson <gu...@gmail.com>
>
>> +0
>>
>> Matt
>>
>>
>> On Tue, May 14, 2013 at 12:30 PM, Thomas Neidhart <
>> thomas.neidhart@gmail.com
>> > wrote:
>>
>> > On 05/13/2013 08:06 PM, Thomas Neidhart wrote:
>> > > Hi,
>> > >
>> > > currently, the Bag interface states that it violates the Collection
>> > > contract. This is mainly because the interface was defined like that,
>> > > but could be easily changed.
>> > >
>> > > As we are not binary compatible anymore with previous releases, it
>> would
>> > > be the right time to do this now (or leave it as it is till the end of
>> > > time).
>> > >
>> > > Any opinions / objections on this?
>> >
>> > As there have been some objections against this change, and I *really*
>> > would like to cut an alpha release soon, I'd like to streamline the
>> > process.
>> >
>> > Everybody is welcome to express his/her opinion on the following options:
>> >
>> > [ ] +1 Yeah do this change, it's really time
>> > [ ] +0 OK great, but we should add a Bag decorator which mimics the
>> >        pre-4.0 behavior
>> > [ ] -0 Well, I do not use collections and guava is cooler anyways
>> > [ ] -1 I want to keep the Bag interface as is, but add a Bag decorator
>> >        which makes it conform to the Collection contract
>> >
>> > Thanks,
>> >
>> > Thomas
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>> > For additional commands, e-mail: dev-help@commons.apache.org
>> >
>> >
>>
>
>
>
> --
> http://people.apache.org/~britter/
> http://www.systemoutprintln.de/
> http://twitter.com/BenediktRitter
> http://github.com/britter

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [collections] Fix Bag interface

Posted by Benedikt Ritter <br...@apache.org>.
+1

since the package name will change, client code has to be changed anyway.
Now is the time to get rid of all flaws of the old API.


2013/5/14 Matt Benson <gu...@gmail.com>

> +0
>
> Matt
>
>
> On Tue, May 14, 2013 at 12:30 PM, Thomas Neidhart <
> thomas.neidhart@gmail.com
> > wrote:
>
> > On 05/13/2013 08:06 PM, Thomas Neidhart wrote:
> > > Hi,
> > >
> > > currently, the Bag interface states that it violates the Collection
> > > contract. This is mainly because the interface was defined like that,
> > > but could be easily changed.
> > >
> > > As we are not binary compatible anymore with previous releases, it
> would
> > > be the right time to do this now (or leave it as it is till the end of
> > > time).
> > >
> > > Any opinions / objections on this?
> >
> > As there have been some objections against this change, and I *really*
> > would like to cut an alpha release soon, I'd like to streamline the
> > process.
> >
> > Everybody is welcome to express his/her opinion on the following options:
> >
> > [ ] +1 Yeah do this change, it's really time
> > [ ] +0 OK great, but we should add a Bag decorator which mimics the
> >        pre-4.0 behavior
> > [ ] -0 Well, I do not use collections and guava is cooler anyways
> > [ ] -1 I want to keep the Bag interface as is, but add a Bag decorator
> >        which makes it conform to the Collection contract
> >
> > Thanks,
> >
> > Thomas
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > For additional commands, e-mail: dev-help@commons.apache.org
> >
> >
>



-- 
http://people.apache.org/~britter/
http://www.systemoutprintln.de/
http://twitter.com/BenediktRitter
http://github.com/britter

Re: [collections] Fix Bag interface

Posted by Matt Benson <gu...@gmail.com>.
+0

Matt


On Tue, May 14, 2013 at 12:30 PM, Thomas Neidhart <thomas.neidhart@gmail.com
> wrote:

> On 05/13/2013 08:06 PM, Thomas Neidhart wrote:
> > Hi,
> >
> > currently, the Bag interface states that it violates the Collection
> > contract. This is mainly because the interface was defined like that,
> > but could be easily changed.
> >
> > As we are not binary compatible anymore with previous releases, it would
> > be the right time to do this now (or leave it as it is till the end of
> > time).
> >
> > Any opinions / objections on this?
>
> As there have been some objections against this change, and I *really*
> would like to cut an alpha release soon, I'd like to streamline the
> process.
>
> Everybody is welcome to express his/her opinion on the following options:
>
> [ ] +1 Yeah do this change, it's really time
> [ ] +0 OK great, but we should add a Bag decorator which mimics the
>        pre-4.0 behavior
> [ ] -0 Well, I do not use collections and guava is cooler anyways
> [ ] -1 I want to keep the Bag interface as is, but add a Bag decorator
>        which makes it conform to the Collection contract
>
> Thanks,
>
> Thomas
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>

Re: [collections] Fix Bag interface

Posted by Emmanuel Bourg <eb...@apache.org>.
Le 14/05/2013 19:30, Thomas Neidhart a écrit :

> Everybody is welcome to express his/her opinion on the following options:
> 
> [ ] +1 Yeah do this change, it's really time
> [ ] +0 OK great, but we should add a Bag decorator which mimics the
>        pre-4.0 behavior
> [ ] -0 Well, I do not use collections and guava is cooler anyways
> [ ] -1 I want to keep the Bag interface as is, but add a Bag decorator
>        which makes it conform to the Collection contract

-1, I think the current behavior of add/remove is clever and very
useful, even if this violates the Collection contract.

Emmanuel Bourg



Re: [collections] Fix Bag interface

Posted by Thomas Neidhart <th...@gmail.com>.
On 05/13/2013 08:06 PM, Thomas Neidhart wrote:
> Hi,
> 
> currently, the Bag interface states that it violates the Collection
> contract. This is mainly because the interface was defined like that,
> but could be easily changed.
> 
> As we are not binary compatible anymore with previous releases, it would
> be the right time to do this now (or leave it as it is till the end of
> time).
> 
> Any opinions / objections on this?

As there have been some objections against this change, and I *really*
would like to cut an alpha release soon, I'd like to streamline the process.

Everybody is welcome to express his/her opinion on the following options:

[ ] +1 Yeah do this change, it's really time
[ ] +0 OK great, but we should add a Bag decorator which mimics the
       pre-4.0 behavior
[ ] -0 Well, I do not use collections and guava is cooler anyways
[ ] -1 I want to keep the Bag interface as is, but add a Bag decorator
       which makes it conform to the Collection contract

Thanks,

Thomas

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [collections] Fix Bag interface

Posted by Thomas Neidhart <th...@gmail.com>.
On 05/13/2013 09:19 PM, sebb wrote:
> On 13 May 2013 19:06, Thomas Neidhart <th...@gmail.com> wrote:
>> Hi,
>>
>> currently, the Bag interface states that it violates the Collection
>> contract. This is mainly because the interface was defined like that,
>> but could be easily changed.
>>
>> As we are not binary compatible anymore with previous releases, it would
>> be the right time to do this now (or leave it as it is till the end of
>> time).
>>
>> Any opinions / objections on this?
> 
> If changing the interface makes more sense, then now is the time to go for it.

ok, I have created COLLECTIONS-468 and attached a patch with the
proposed changes. Now the Bag tests can also inherit from
AbstractCollectionTest, which improves the test coverage.

Please review, and if there are no objections, I will go ahead with the
change.

Thomas

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [collections] Fix Bag interface

Posted by sebb <se...@gmail.com>.
On 13 May 2013 19:06, Thomas Neidhart <th...@gmail.com> wrote:
> Hi,
>
> currently, the Bag interface states that it violates the Collection
> contract. This is mainly because the interface was defined like that,
> but could be easily changed.
>
> As we are not binary compatible anymore with previous releases, it would
> be the right time to do this now (or leave it as it is till the end of
> time).
>
> Any opinions / objections on this?

If changing the interface makes more sense, then now is the time to go for it.

> Thomas
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org