Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2005

Tip: Looking for answers? Try searching our database.

replacing duplicate object on client

Thread view: 
VisionSet - 09 Dec 2005 15:30 GMT
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
Danno - 09 Dec 2005 16:12 GMT
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. ;)
VisionSet - 09 Dec 2005 17:07 GMT
> How do we know what it does?

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

--
Mike W
Danno - 09 Dec 2005 23:01 GMT
So what does this have to do with your post?
Oliver Wong - 09 Dec 2005 23:06 GMT
> 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
Danno - 10 Dec 2005 06:57 GMT
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.
Luc The Perverse - 10 Dec 2005 10:46 GMT
> 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.

You should quote who you are replying to.

That goes a long way too

--
LTP

:)
Danno - 10 Dec 2005 18:42 GMT
Yep. FYI, I was referring to the original post.

<copy>
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
Signature

Mike W

</copy>

Oliver Wong - 09 Dec 2005 16:12 GMT
> Client Server - client is MVC server holds objects of same type as are
> contained in the M of clients MVC
[quoted text clipped - 15 lines]
> 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
Chris Uppal - 09 Dec 2005 17:41 GMT
> 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
VisionSet - 09 Dec 2005 17:57 GMT
> > a/ copy all the observers out of the old one into the new one and replace
> > the object
[quoted text clipped - 7 lines]
> 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
Thomas Hawtin - 09 Dec 2005 22:50 GMT
> 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
Signature

Unemployed English Java programmer
http://jroller.com/page/tackline/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.