Re: Determine if an item in a collection has changed
- From: "Larry Serflaten" <serflaten@xxxxxxxxxxxxxx>
- Date: Thu, 17 Nov 2005 21:02:51 -0600
"Dmitriy Antonov" <antonovdima@xxxxxxxxxxxxxxxxxxxxxxxx> wrote
Responses inline....
> I disagree with your first statement about what was evident. Citation: "It's
> there an easy way to determine if one or more objects in a collection
> has changed, without enumerating the collection ..."
That was his first post, he added a second post which clarified the issue:
------------
>> Obviously, in PP.Save, i could enumerate each Person instance and call the
>> .Save method if the instance needed persistance, but i'd rather be smart
>> about it.
------------
That is the message I responded to, I did not reply to his first post.
> In original post there was no question about how to query all children. And
> your first solution effectively proposed just that. And this is why I raised
> all my doubts. OP asked how to avoid querying of all of them.
And there you have the reason why an alternate method was suggested.
He asked how to avoid querying all of the kids. My suggestion was to
have the kids respond to an event.
> It can be
> done only by means of notifications (in wide sense of this word - not
> necessary in the form of blinking label in GUI). Each time, when collection
> member has changed, it must notify some central unit about it.
You are the one that is making the supposition that the parent needs to be
notified when a child is changed. That is not what the OP asked for. While
you can get it to work, you add in complication that was not asked for.
> I don't see a reason to employ fourth, fifth and further classes just to
> organize normal work of simple collection - again, unnecessary complication
> with no benefits at all (and just an opposite), while technically you can
> complicate any simple schema to continue be workable, just inefficient :-)
Persoanl preference I suppose. I'd rather go that route than muck around
with weak references. They may have their place, but they are for the
more advanced users, possibly the same type that will subclass their controls
to add one more 'feature' or function... I prefer to stay within the bounds
of the VB language when possible, especially when the difference in code
size is not going to be that significant. As you noted, performance is relative.
If it functions at acceptable rates, its acceptable....
> When you use something, like recently proposed Notify method in the
> Messenger, it becomes reasonable in sense of reaching OP's goal - the next
> step is to organize a list of changed items (in the Messenger itself or in
> the collection class) and then this list to be used instead of looping all
> children. This is how I understand OP.
I see you maintain a second collection for the changed items. If you implement
that idea in a heirarchy of collection objects, you'll also add to the complexity,
just as you said using a messenger would. Whereas the same messenger class
(different objects, same class) can be used for all the levels to get the changed
list when needed, you'd have multiple collections at all the levels that stay in
memory until saved. I think there are advantages to reserve building that
collection until the time it is actually needed, memory use being one of those
reasons. In the end, both methods could be made to work, I would
suggest the method that the OP can easily understand and implement
would be a good suggestion, regardless of which method that is.
I favor the classes approach as being the simpler approach, over weak
references, but everyone is different....
LFS
.
- Follow-Ups:
- Re: Determine if an item in a collection has changed
- From: Dmitriy Antonov
- Re: Determine if an item in a collection has changed
- References:
- Re: Determine if an item in a collection has changed
- From: Dmitriy Antonov
- Re: Determine if an item in a collection has changed
- From: Craig Buchanan
- Re: Determine if an item in a collection has changed
- From: Larry Serflaten
- Re: Determine if an item in a collection has changed
- From: Dmitriy Antonov
- Re: Determine if an item in a collection has changed
- From: Larry Serflaten
- Re: Determine if an item in a collection has changed
- From: Dmitriy Antonov
- Re: Determine if an item in a collection has changed
- Prev by Date: Re: [MULTIPOSTED] copying string "A" to string "B" using a pointer to string B
- Next by Date: Re: Determine if an item in a collection has changed
- Previous by thread: Re: Determine if an item in a collection has changed
- Next by thread: Re: Determine if an item in a collection has changed
- Index(es):
Relevant Pages
|
Loading