Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > replacing duplicate object on client

Reply
Thread Tools

replacing duplicate object on client

 
 
VisionSet
Guest
Posts: n/a
 
      12-09-2005

Client Server - client is MVC server holds objects of same type as are
contained in the M of clients MVC

For the sake of this thread lets assume this is a reasonable design for my
system.

Object arrives at client and is equivalent but obviously more upto date than
one already held by client.
Client wants to replace the old one with the new one.

Does it:

a/ copy all the observers out of the old one into the new one and replace
the object
b/ copy the data out of the new one into the old one
c/ replace the object and let some other observer mechanism sort refresh
whatever
d/ something else I haven't considered.

TIA
--
Mike W


 
Reply With Quote
 
 
 
 
Danno
Guest
Posts: n/a
 
      12-09-2005
How do we know what it does? You programmed it. Unless this is some
sort of brand-named server you forgot to mention?

Let us know.

 
Reply With Quote
 
 
 
 
Oliver Wong
Guest
Posts: n/a
 
      12-09-2005

"VisionSet" <(E-Mail Removed)> wrote in message
news:mqhmf.1947$(E-Mail Removed)...
>
> Client Server - client is MVC server holds objects of same type as are
> contained in the M of clients MVC
>
> For the sake of this thread lets assume this is a reasonable design for my
> system.
>
> Object arrives at client and is equivalent but obviously more upto date
> than
> one already held by client.
> Client wants to replace the old one with the new one.
>
> Does it:
>
> a/ copy all the observers out of the old one into the new one and replace
> the object
> b/ copy the data out of the new one into the old one
> c/ replace the object and let some other observer mechanism sort refresh
> whatever
> d/ something else I haven't considered.
>


I would go with 'b'. For your client-side model object, I'd have a
method "updateFrom(Model m)" or something like that, so all you have to do
is pass in the new Model object into the old one, then discard the new Model
object. The updateFrom() method should take care of only sending
notifications for the fields that actually did change.

- Oliver


 
Reply With Quote
 
VisionSet
Guest
Posts: n/a
 
      12-09-2005

"Danno" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...

> How do we know what it does?


http://en.wikipedia.org/wiki/Abstraction

--
Mike W


 
Reply With Quote
 
Chris Uppal
Guest
Posts: n/a
 
      12-09-2005
VisionSet wrote:

> a/ copy all the observers out of the old one into the new one and replace
> the object
> b/ copy the data out of the new one into the old one
> c/ replace the object and let some other observer mechanism sort refresh
> whatever
> d/ something else I haven't considered.


Probably (c) and/or (d). You already have code that connects your client code
to a model (or how come it is already observing the old model). Run that code
again with the new model. If it takes more than one line of new code then
you've done something wrong

-- chris



 
Reply With Quote
 
VisionSet
Guest
Posts: n/a
 
      12-09-2005

"Chris Uppal" <(E-Mail Removed)-THIS.org> wrote in message
news:4399c193$0$258$(E-Mail Removed)...
> VisionSet wrote:
>
> > a/ copy all the observers out of the old one into the new one and

replace
> > the object
> > b/ copy the data out of the new one into the old one
> > c/ replace the object and let some other observer mechanism sort refresh
> > whatever
> > d/ something else I haven't considered.

>
> Probably (c) and/or (d). You already have code that connects your client

code
> to a model (or how come it is already observing the old model). Run that

code
> again with the new model. If it takes more than one line of new code then
> you've done something wrong
>


I guess that is the best general approach, just that the 1st time the object
is installed on the client an observer mechanism causes new gui components
to be created to render it. Subsequent updates shouldn't create new GUI
elements or even have any gui component destruction/creation effect, just
trigger paint updates. Just need to think a bit harder about this one. I
guess it will be a case of firing an insert or an update sort of event and
letting the gui figure it out.

--
Mike W


 
Reply With Quote
 
Thomas Hawtin
Guest
Posts: n/a
 
      12-09-2005
VisionSet wrote:
>
> a/ copy all the observers out of the old one into the new one and replace
> the object
> b/ copy the data out of the new one into the old one
> c/ replace the object and let some other observer mechanism sort refresh
> whatever
> d/ something else I haven't considered.


You probably want to keep the object identity intact if there are users
of it. So I would tend towards b.

Replication is quite difficult. If you can guarantee good enough quality
of communication, thing become easier if you can make sure that all
modifications are done either in one place or with distributed locks
enforced. A handy strategy is to replay the actions that caused the
mutations, rather than trying to compare data.

Another useful (and indeed have good performance from the client view of
things) approach is to forget about small scale listeners and just sync
the whole lot. It can mean much less code without all those listeners.
It has good performance because there isn't the high set up time and in
the case of lots changing there aren't all those events, just a single
process. It's much slower on smaller updates, but who cares about
performance of what will be fast anyway.

Tom Hawtin
--
Unemployed English Java programmer
http://jroller.com/page/tackline/
 
Reply With Quote
 
Danno
Guest
Posts: n/a
 
      12-09-2005
So what does this have to do with your post?

 
Reply With Quote
 
Oliver Wong
Guest
Posts: n/a
 
      12-09-2005

"Danno" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> So what does this have to do with your post?
>


I think VisionSet is saying you don't need to know what his program does
to answer the specific design question of how to synchronize two different
model objects.

- Oliver


 
Reply With Quote
 
Danno
Guest
Posts: n/a
 
      12-10-2005
An attempt at good grammar goes a long way I guess.
Sounded like he already had a server, and wanted to know how it worked.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Object-arrays - duplicate object-references Are Nybakk Javascript 11 04-12-2008 06:05 PM
Removing Duplicate Objects from Object List Jeff Nyman Ruby 8 10-10-2006 03:44 PM
Object creation - Do we really need to create a parent for a derieved object - can't the base object just point to an already created base object jon wayne C++ 9 09-22-2005 02:06 AM
Replacing - and not Replacing... Rob Meade ASP General 5 04-11-2005 06:49 PM
How to clone/duplicate a TableCell object Chris Becker ASP .Net 0 04-01-2004 12:34 AM



Advertisments