title: How to handle data bindings that are related?
body: <p>I often find myself running into problems where two (related) values of a control get updated, and both would trigger an expensive operation, or possibly the control could get temporarily in an inconsistent state.</p>
  
  <p>For example, consider a data binding where two values (x,y) get substracted from each other, and the end result is used as a divisor for some other property z:</p>
  
  <p>z / (x - y)</p>
  
  <p>If x and y are bound to some external value, then updating them one at a time could lead to unexpected division by zero errors, depending on which property gets updated first and what the old value of the other property is.  The code that updates property z just listens on changes in both x and y -- it has no way of knowing in advance that another update is coming for the other property.</p>
  
  <p>Now this problem is fairly easy to avoid, but there are other similar cases, like setting width and height... do I resize the window right away or wait for another change?  Do I allocate memory for the specified width and height right away or do I wait?  If the width and height was 1 and 1 million, and then gets updated to 1 million and 1, then temporarily I'd have a width and height of 1 million x 1 million...</p>
  
  <p>This can be a fairly general question, although for me specifically it would apply to  JavaFX Bindings.  I'm interested in ways how to deal with these situations without running into undefined behaviour or doing expensive operations that need to be redone as soon as another binding changes.</p>
  
  <p>The thing I've done so far to avoid these situations is to clear bindings first to known values before setting new values, but this is a burden on the code updating the bindings that it really shouldn't have to know about.</p>