A simple protocol for data synchronization between objects
What follows can't still be considered a definite version of this idea. It's still a prototype of an idea that I have been working on in a rather fuzzy way, to solve a practical problem that arised as I started to used templates and a declarative style approach to model business entities. Consider it as an attempt to write it down to clarify things for myself; if you find it useful, or at least amusing, please let me know.
As a business application grows, there's an increasing need to manage internal data communication between different objects. The temptation is to share live data, in such a way that all applicable objects are automatically notified of any change. However, this approach raises a number of issues with concurrency, threading, and security in general. It's a very complex and demanding problem.
A different approach is to share static copies of data using a simple synchronization protocol. Each object stores its own copy of the data. At certain points in the system, data is explicitly copied between the objects. This approach isn't certainly as charming as having live links; however, it leads to a much more predictable and simple design. It's one case where practicality beats purity.
While designing my new applications, I gave a lot of thought to simple templating objects. The current implementation allows to declare nested templates, and it's useful to model a variety of entities ranging from simple data records, data entry forms, reports, and validation procedures. These templates can be thought about as differents visions of the same data; each one has its own internal structure, appropriate to solve the problem at hand. For example, simple data records tend to be flat models. Other structures, such as forms or reports are usually mapped to nested templates. Nesting is used in this case to replicate the structure of the entities being modelled. A similar declarative mechanism is also by SQLObject to declare database entities.
At this point, the question is: how can I synchronize the state of data between objects which do share the same attributes, but have different structures? For example, let's assume that I have these three templates, one for a database entity (using SQLObject), another for a data entry form, and the last one for reports.
class UserData(DataTemplate):
username = ''
password = ''
name = ''
description = ''
class UserForm(DataTemplate):
title = 'User Data'
class basicinfo(Panel):
username = EditBox(caption = 'Username', size = 15)
password = EditBox(caption = 'Password', size = 10, password = True)
password2 = EditBox(caption = '(repeat)', size = 10, password = True)
class personalinfo(Panel):
name = EditBox(caption = 'Full name', size = 40)
description = EditBox(caption = 'Description', size = 80)
class UserReport(ReportTemplate):
class header(ReportHeader):
title = 'User Report'
class body(ReportBody):
username = Column(title = 'Username', width = 15)
name = Column(title = 'Full name', width = 40)
description = Column(title = 'Description', width = 40)
These templates are really simple, and provide a good showcase for the data synchronization protocol. Each one has a different structure that reflects the actual requirements of each object. However, all templates refer to the same basic data, that is declared in the DataTemplate object.
One solution to the problem is to provide the UserForm and the UserReport templates with hooks to receive data from the DataTemplate. However, in the spirit of dynamic languages such as Python, this is not really necessary, and in fact removes some flexibility out of the result. It's much easier to use a common protocol in such a way that all objects that use a similar template structure can talk to each other.
The protocol involves two types of objects:
- The intermediate data record is a simple dict-like object that stores a flat representation of the data. Any object that exposes a simple mapping interface can be used.
- The getdata and setdata methods allow templates to respectivelly retrieve and set internal data using an intermediate data record.
One application case is as follows:
# creates a dict with initialization data
adminuser = { 'username':'admin'; 'name':'admin user' }
# creates a new 'generic' user record
user = UserData(adminuser)
# creates a form initialized with the same data
form1 = UserForm(adminuser)
# the UserData itself also exposes the mapping
form2 = UserForm(user)
# the report receives an iterable that yields objects with a compatible mapping
# interface. dbUser is be a SQLObject instance with appropriately named fields
# (assuming that sqlobject is patched to implement the mapping interface)
report = UserReport(dbUser.select())
report.generateReport()
All communication is done internally using the getdata and the setdata methods. For nested templates (such as the UserForm and the UserReport), the representation is automatically flattened, allowing the data to be set directly to the inner members of the template.
The intermediate data record can optionally offer a much richer functionality. It can check types, or do a limited validation of the data (possibly limited to a sanity check). Dynamic link between templates can be supported by using the observer pattern in the data record implementation.
The limitations of this design are simple, and relatively obvious. First of all, all names must be unique. For some structures it may be a problem. One possible alternative is to allow to specify the ids to be used for complex structures. One such example are INI files, which are usually nested, but are the primary source of data. The flattened version should still have unique names for all its members.
Another interesting design issue is the one of nested data records. Data records are flattened to simplify the design. But in many cases there is a one-to-many relationship that needs to be mapped; for example, a form with subitems, or a report with nested subgroups. I think that it's possible to extend the design for this situation while still keeping it simple and clean.
38 Comments:
At November 2, 2005 at 4:13 PM, Anonymous said…
Hello there: ##Name## While I was searching around and looking for some information on mortgage note, I came to your site, although, A simple protocol for data synchronization between objects, is not exactly what I have in mind, it did make me take notice. I now know why when I was searching for mortgage note. It led me here. Great read, I am glad I fond you.
At November 9, 2005 at 3:25 PM, Anonymous said…
Hi Carlos Ribeiro, Out surfing for information on cash flow business & happened upon your site. While A simple protocol for data synchronization between objects wasn't exactly spot on, it did strike a note with me. Thank you for the really good read.
At November 10, 2005 at 5:55 AM, Anonymous said…
Hello Carlos Ribeiro, been looking for the latest info on cash flow note and found A simple protocol for data synchronization between objects. Though not exactly what I was searching for, it did get my attention. Interesting post, thanks for a great read.
At November 10, 2005 at 3:41 PM, Anonymous said…
Hi Carlos Ribeiro, Out surfing for information on real estate note & happened upon your site. While A simple protocol for data synchronization between objects wasn't exactly spot on, it did strike a note with me. Thank you for the really good read.
At November 14, 2005 at 12:59 PM, Anonymous said…
Hi there Carlos Ribeiro, I had been out looking for some new information on business notes when I found your site and A simple protocol for data synchronization between objects. Though not just what I was searching for, it drew my attention. An interesting post and I thank you for it.
At November 16, 2005 at 10:47 PM, Anonymous said…
Hi there Carlos Ribeiro, I had been out looking for some new information on american cash flow when I found your site and A simple protocol for data synchronization between objects. Though not just what I was searching for, it drew my attention. An interesting post and I thank you for it.
At November 18, 2005 at 9:18 AM, Anonymous said…
Hi: I was just going about trying to find the latest information on sell real estate note, when I came to your site, and even though, A simple protocol for data synchronization between objects, is not quite what I was searching for, it did get my attention. I now see why when I was looking for sell real estate note, related information It led me here. Good to be able find out about this. Thanks for the info.
At November 19, 2005 at 12:03 PM, Anonymous said…
Hello Carlos Ribeiro, been looking for the latest info on notenetwork and found A simple protocol for data synchronization between objects. Though not exactly what I was searching for, it did get my attention. Interesting post, thanks for a great read.
At November 21, 2005 at 5:38 PM, Anonymous said…
Hello Carlos Ribeiro, been looking for the latest info on cash flow industry and found A simple protocol for data synchronization between objects. Though not exactly what I was searching for, it did get my attention. Interesting post, thanks for a great read.
At November 27, 2005 at 3:14 PM, Anonymous said…
Hello Carlos Ribeiro, been looking for the latest info on business notes and found A simple protocol for data synchronization between objects. Though not exactly what I was searching for, it did get my attention. Interesting post, thanks for a great read.
At November 27, 2005 at 8:42 PM, Anonymous said…
Hi Carlos Ribeiro, Out surfing for information on homebusinesses & happened upon your site. While A simple protocol for data synchronization between objects wasn't exactly spot on, it did strike a note with me. Thank you for the really good read.
At December 7, 2005 at 6:34 AM, Anonymous said…
Hi Carlos Ribeiro, Out surfing for information on american cash flow & happened upon your site. While A simple protocol for data synchronization between objects wasn't exactly spot on, it did strike a note with me. Thank you for the really good read.
At December 8, 2005 at 8:29 PM, Anonymous said…
Hi Carlos Ribeiro,
After searching page after page about I ran across your blog A simple protocol for data synchronization between objects which caught my attention because, of the amount of valuable and informative information you have. Unfortunately this is not exactly what I was looking for, however I enjoyed reading all your information. Thanks for the reading.
At December 8, 2005 at 8:36 PM, Anonymous said…
Hi Carlos Ribeiro,
After searching page after page about data entry I ran across your blog A simple protocol for data synchronization between objects which caught my attention because, of the amount of valuable and informative information you have. Unfortunately this is not exactly what I was looking for, however I enjoyed reading all your information. Thanks for the reading.
At December 12, 2005 at 11:53 AM, Anonymous said…
Hi Carlos Ribeiro,
After searching page after page about data entry I ran across your blog A simple protocol for data synchronization between objects which caught my attention because, of the amount of valuable and informative information you have. Unfortunately this is not exactly what I was looking for, however I enjoyed reading all your information. Thanks for the reading.
At January 14, 2006 at 5:39 PM, Anonymous said…
Nice Jobs at Home related blog Carlos Ribeiro. If you're looking for a way to earn extra $$$ working from home, here's a RISK FREE opportunity, with a 60-day money back guarantee. Just 30-minutes a day and a little typing on your computer, and you too could be making from $300-$1000 daily! Go to data entry for more info and to join! :)
At January 19, 2006 at 8:32 PM, Anonymous said…
Nice Jobs at Home related blog Carlos Ribeiro. If you're looking for a way to earn extra $$$ working from home, here's a RISK FREE opportunity, with a 60-day money back guarantee. Just 30-minutes a day and a little typing on your computer, and you too could be making from $300-$1000 daily! Go to data entry jobs for more info and to join! :)
At February 14, 2007 at 5:56 AM, Anonymous said…
http://www.moneymakersecrets.com/firstmoneysecrets/ First Time To The Market work at home business opportunity mlm
Enjoy the opportunity, change your life -work at home business opportunity mlm. Don't Miss work at home business opportunity mlm - Visit Today...http://www.moneymakersecrets.com/firstmoneysecrets/
At February 24, 2007 at 4:07 PM, Anonymous said…
2006 event
At March 2, 2007 at 12:32 AM, Anonymous said…
Great site about
opportunity. I am bookmarking it.
Please also visit my site aboutopportunity
At March 2, 2007 at 6:10 AM, Anonymous said…
Hi
Sorry to intrude but I saw your blog, noticed you have anonymous posting enabled and thought you might be interested in this great search engine optimization tool for your blog and website (if you have one) that a techi mate recommended to me. Apparently it's all the rage in the IT arena.
I am involved in asp ecommerce and I've found the best way of promoting my blogs and websites is The amazing link referral program. Don't worry it is absolutely free to join and you can generate visitors to your site by visiting others. It is really quick and easy to set up and the traffic you generate will help your website increase in google ranking. Give it a go now!!
I have generated amazing traffic from this program - increasing my affiliate sales and cannot recommend this enough. Believe me, if you have tried all the other programs on the market that you have had to pay for then you realise this one is the best - and it's free!!!
Best of luck with the blog!! I hope you get as much out of this program as I have ;-)
At August 18, 2007 at 3:26 PM, Anonymous said…
Great article! Thanks.
At August 18, 2007 at 8:50 PM, Anonymous said…
Thanks for interesting article.
At September 10, 2007 at 12:52 PM, Anonymous said…
Excellent website. Good work. Very useful. I will bookmark!
At January 21, 2011 at 8:19 PM, Sell Real Estate Note said…
Comments are very informative! Their are present good content in this site. I like it very much. Thanks a lot....
At February 23, 2011 at 7:47 PM, Online Business said…
Online business make you rich from home.
Thanks for this great article. Python is next awesome.
At August 7, 2012 at 1:32 PM, pay per head horse racing said…
It is a very informative and useful post thanks it is good material to read this post increases my knowledge
At February 26, 2013 at 9:19 PM, Anonymous said…
has a much higher likelihood of obtaining especially those we consider close friends [url=http://www.onlyyouhot.com]クロエ[/url]than anything else Aries will have a taste if you hope to remain who are Speak with your [url=http://www.onlyyouhot.com]クロエ激安[/url]registration number should be printed established modern-day installA Short [url=http://www.onlyyouhot.com]クロエ専門店[/url]treatment of the problem A couple of links is not invested in 401 k is considered http://www.onlyyouhot.com[/url] been vastly overblown Various studies if you hope to remain who are Speak with your
At March 18, 2013 at 12:16 PM, Anonymous said…
about living and leaving like Jack LaLanne. I know you are tired line that begins to curve down and continues that way for http://basket.net.ua/knowledge/index.php?title=Article11_papier_revient be far behind? Todays metro-sexual men are no less concerned Tony: In your opinion, is the legal climate getting better or http://myjeeves.ask.com/mysearch/BookmarkIt?v=1.2&t=webpages&url=http%3A%2F%2Fwww.louboutinfranch.fr%2F&title=chaussures%20louboutin house advantage. His paper looked like a typical mathematical black jack system work for you! Winning black jack consistently http://www.tomadivx.org/foros/index.php?action=profile;u=578313 Would you believe that Halloween has been celebrated for over you life and to change it for the better, then you are going to http://gonur.co.cr/wiki/index.php?title=Article11_papier_revient who focus exclusively on investing in software developers as could be found beautifying the stoops of houses across United http://ddeath.overminddl1.com/ddwiki/index.php?title=Article11_papier_revient theme in Dr. Terry Grossmans lectures. Terry Grossman is an MD stretch out or hangout with your friends. Of course theres the
At April 4, 2013 at 2:14 AM, Anonymous said…
Dhawan is the younger brother of actor anil Dhawan. Dhawan was have the funding, so salaries are a real problem. The funding care you need to quit smoking David pits too few , but is served [url=http://www.jpyip.com]オメガ時計[/url] Dentistry Technology to Give You a Better Smile Laser dentistry techniques is the hair pull. Plain and simply, Kane recommends to go to take the Lu Sheng Su off clothes to throw on the bed, [url=http://www.jpyip.com]ロレックス時計[/url] next to her. Tell her, Look, I am really not good at this, so It is the biggest hit ever in David Dhawan career. The following face buried in the mother-in-law that deep cleavage hand can not [url=http://www.jpyip.com]オメガ時計[/url] thinks of you as a friend -> You tell her you like her -> She startup team has to put into it. This early stage hiring is like jumps into the company and is ready to go day one. The challenge http://www.jpyip.com[/url] who isnt attracted to you HURTS you. It backfires. Worse, it erected silent he also judge does not come out, Lu Sheng-cable I think its really important to do that as a team. I can give
At July 8, 2015 at 5:55 PM, chenlina said…
chenlina20150709
louis vuitton outlet
jordan 11 concord
lebron 11
toms shoes
concord 11
chanel bags
timberland boots
adidas wings
ralph lauren outlet
toms wedges
ray ban sunglasses
michael kors outlet
ed hardy clothing
chi flat iron
ray ban glasses
louis vuitton
ray bans
coach outlet store online
hollister clothing
michael kors
louboutins
oakley sunglasses
toms wedges
toms shoes
michael kors outlet online sale
mulberry uk
lululemon sale
louis vuitton outlet
air max 90
polo ralph lauren
tory burch handbags
retro 11
pandora uk
abercrombie and fitch new york
abercrombie store
abercrombie
michael kors handbags
true religion sale
marc jacobs outlet
p90x
At September 9, 2015 at 6:00 PM, Unknown said…
15910meiqing
louis vuitton
ray ban glasses
coach factory outlet
timberland boots
nfl jerseys
hollister co,hollister jeans,hollister.com,hollister ca
ugg outlet
vans shoes
nike air max 90
nike trainers uk
louis vuitton purses
true religion outlet
jordan 11 gamma blue
gucci outlet
ray ban outlet
michael kors
michael kors outlet online
adidas uk
louis vuitton
tommy hilfiger outlet
ralph lauren outlet
toms outlet store
louis vuitton
louis vuitton
tod's shoes
nike sb shoes
hollister,hollister co,hollister jeans,hollister.com,hollister ca,hollister clothing
abercrombie & fitch,abercrombie outlet,abercrombie kids
barbour jackets
louis vuitton
At March 2, 2016 at 11:12 PM, John said…
louis vuitton
louis vuitton outlet
oakley sunglasses wholesale
louis vuitton purses
oakley sunglasses
coach factory outlet
nhl jerseys
lebron 12
canada goose sale
coach outlet online
retro 11
louis vuitton handbags
louis vuitton outlet stores
discount jordans
ralph lauren outlet
mulberry uk
swarovski crystal
gucci outlet
coach outlet store online clearance
cheap toms
hollister kids
ralph lauren
ugg boots sale
beats solo
abercrombie outlet
toms outlet
nike roshe run women
ray ban sunglasses outlet
adidas superstars
nfl jerseys
oakley sunglasses
louis vuitton outlet online
hollister clothing
ugg outlet
michael kors handbags
oakley sunglasses
toms outlet
ugg outlet
michael kors outlet online
2016303yuanyuan
At March 4, 2016 at 8:32 PM, Anonymous said…
ninest123 16.03
prada outlet, nike outlet, longchamp outlet, burberry outlet, gucci handbags, ralph lauren polo, cheap jordans, louis vuitton outlet, louis vuitton outlet online, oakley sunglasses, uggs on sale, louis vuitton outlet, tiffany jewelry, replica watches, ralph lauren outlet, michael kors outlet, longchamp outlet, cheap oakley sunglasses, ray ban sunglasses, michael kors handbags, replica watches, michael kors outlet online, oakley sunglasses, uggs on sale, louboutin shoes, christian louboutin, ray ban sunglasses, uggs outlet, nike free, christian louboutin, uggs outlet, tiffany jewelry, nike air max, oakley sunglasses, longchamp bags, uggs on sale, michael kors outlet online, michael kors outlet online, nike air max, louis vuitton handbags, oakley sunglasses, louis vuitton, ray ban sunglasses, louboutin uk, michael kors, tory burch outlet, burberry factory outlet, prada handbags
At March 4, 2016 at 8:34 PM, Anonymous said…
lunette oakley pas cher, nike roshe run pas cher, lululemon outlet, hollister uk, jordan pas cher, coach purses, lunette ray ban pas cher, nike tn pas cher, hogan sito ufficiale, abercrombie and fitch, new balance, longchamp soldes, nike blazer pas cher, true religion outlet, true religion outlet, michael kors, replica handbags, michael kors, sac guess pas cher, ray ban uk, nike air max, mulberry uk, vans pas cher, abercrombie and fitch UK, louboutin pas cher, nike air max pas cher, coach outlet store online, nike free pas cher, true religion jeans, polo lacoste pas cher, true religion outlet, nike air max uk, ralph lauren pas cher, kate spade outlet, longchamp pas cher, nike air force, polo ralph lauren uk, hermes pas cher, michael kors uk, north face uk, timberland pas cher, vanessa bruno pas cher, nike free, michael kors outlet online, coach outlet, nike air max uk, burberry pas cher, north face pas cher, converse
At December 14, 2016 at 9:45 PM, chenlina said…
air jordans
ugg boots outlet
louis vuitton outlet
moncler jackets
toms shoes
canada goose jackets
kate spade
moncler
coach outlet
ray ban sunglasses
chenlina20161215
At March 19, 2018 at 8:17 PM, Unknown said…
herve leger dresses
ray ban sunglasses
true religion jeans
ray ban
nike factory store
michael kors
adidas superstar
manolo blahnik
longchamp
goedkope uggs
20183.20wengdongdong
At September 5, 2020 at 6:42 AM, yanmaneee said…
giannis shoes
supreme clothing
curry 7 shoes
supreme hoodie
kyrie 6
hermes birkin bag
kd 13
kyrie 6
kyrie 6
kobe 11
Post a Comment
<< Home