Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Data Latency in GUIs

 
Simon Ritchie
Ranch Hand
Posts: 95
4
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

I'm working on an application for my employer that features a JavaFX GUI.  The GUI allows users to perform simple updates on Oracle database tables.  Users can add new records, amend existing ones, etc.  All pretty basic stuff.  I demoed the software to my boss who asked what kind of safeguard there is in cases where a user edits a record that's already been edited by someone else (or by the system) in the time since they loaded the GUI.  My code has no facility for multithreading or periodically refreshing the data.

In very broad terms, does anyone have any recommendations on how I can design the application so that users are alerted to data that is already updated?

Thanks
 
Paul Clapham
Sheriff
Posts: 21576
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you design the application to only update the database columns which the user changed, then arguably that answers the manager's concern.

Let's suppose you have a Customer pane with name, address, and credit limit. It might happen that Person A wants to change the address and Person B wants to change the credit limit. If things happen in this order:

1. Person A displays the pane

2. Person B displays the pane

3. Person A updates the data with address changed

4. Person B updates the data with credit limit changed

then if the design simply updates all of the data, then Person B over-writes Person A's change with the old version of the address. However if the design updates only the changed data items then Person B's update doesn't affect the new address which Person A just updated.

The manager might respond to this by asking what happens when two users try to update the credit limit at the same time. The answer of course is that the latest change wins... but it's the business's fault for arranging things so that two people want to change the credit limit to two different values at the same time. You could consider logging all changes so that if this sort of thing happens you can go through the logs and point to the case where two users were trying to make incompatible changes to the data at exactly the same time.
 
Claude Moore
Ranch Hand
Posts: 829
7
IBM DB2 Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Besides Paul's advice - that is a good approach - you may try to implement some locking mechanism at application level, using a strategy  based upon some kind of versioning of the data the record represents.
For example, Hibernate ORM uses this approach..  Even if you don't want or you can't use Hibernate (for any reason) you may take inspiration from this approach.
 
Simon Ritchie
Ranch Hand
Posts: 95
4
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks both.  I'm using Hibernate as it happens (though I'm new to Hibernate) so I'll take a look at the link Claude posted.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic