On Wed, Nov 11, 2009 at 1:13 AM, Dirk Olmes <dir..anthippe.ping.de> wrote:
>> Right. They are...but this (I believe) is too easily exposed to user
>> code. e.g.,
>> for (Bar relation : foo.allBars()) {
>> if (some condition) {
>> foo.removeFromAllBars(relation); // will throw exception
>> }
>> }
>
> Err, why is this? Because you're modifying the collection you're
> iterating over? I'd rather fix the iterator then.
The "problem" exists outside the context of an iterator, too. What
would you expect the semantics to be of the following?
foo.allBars.remove(for.allBars.get(0));
Should it just modify the in-memory list or should it represent the
backing DB and represent a DELETE operation?
It gets a little worse when you add your own custom collection methods
(i.e., not DB backed) and it's not clear what type you're working
with.
Don't get me wrong, it's wholly a human problem. But, false
expectations can lead to tedious debugging sessions and adoptions of
seemingly tenuous programming habits.
-- Kevin
This archive was generated by hypermail 2.0.0 : Wed Nov 11 2009 - 10:45:51 EST