Simberon Design Minute
 

React Update

There are two kinds of user interface windows. Those that just capture information and store it in a domain object and those that have complex interactions between different controls on the user interface. For the simple ones, it's easy to use a simple approach. Simply update the window when it opens so it reflects the state of the object it's editing, then capture the values from the user interface when the user hits Ok and store those values into the object. The windows with complex interactions, however, are more difficult. I often see a tendency to have the user interface code both writing to the domain objects and trying to keep other parts of the user interface in sync with the changes that were just made. It doesn't take long before this becomes a mess of spaghetti code.

One of the best ways I've seen to handle complex user interfaces is called React Update. The idea is that every control on the window triggers a react method. That method reads the information from the control and writes it into the domain object. It then calls update. The update method is responsible for getting all the information from the domain objects reflected properly on the user interface. By following this two-stage approach, you de-couple controls from each other. Each control only needs to worry about how to modify the domain object. The update method can be called at any time to refresh the UI. This approach tends to simplify complex user interfaces and make it easier to figure out how to make changes to them in the future.

Download