Re: Determine if an item in a collection has changed




"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

.



Relevant Pages

  • Re: The origin of science
    ... you should reason. ... statistical tests are *VERY* important. ... why is it only your messenger is allowed to see God and the angels? ... then i would rather that _everyone_ hears this from God himself or from ...
    (sci.math)
  • Re: Is this a double submit problem?
    ... Applications like yours are the reason why we ... var myForm = document.getElementById, myFormSubmitted = false; ... reenters the VerySlowJavaScriptFunction() again. ... See my reply to your first post for suggestions about how to prevent ...
    (comp.lang.javascript)
  • Re: false portscan alarm
    ... What is the reason of that treffic? ... which each have a local source port above 1024 opened outgoing to port 80 ... Windows Messenger? ... UDP packets from that IP have been MSN/Windows messenger spam (which is ...
    (comp.security.firewalls)
  • RE: Welcome to the "ubuntu-users" mailing list
    ... This is also a reason why people shy away from the OSS community. ... You are too lazy to create a new mail with a good subject for you first post ... This message was sent using IMP, the Internet Messaging Program. ...
    (Ubuntu)
  • Re: Sheila got a ? for you
    ... my first post. ... This *biting* honestly is the reason I was reluctant to start ... would like to think I don't *bite* until provoked quite a bit...I have a ... Dani ...
    (sci.med.transcription)

Loading