Observer-Conditioned-Observable Design Pattern.

Douglas A. Lyon, Carl F. R. Weiman · The Journal of Object Technology · 2007

The Observer-Conditioned-Observable (OCO) combines digitizing and transcoding of numeric change events.During the processing of numeric events, the transcoder converts the number from one range into another while preserving the mathematical integrity of the value.Numeric controllers that generate such events can be based in floating point numbers or integer numbers.For example, the JSpinners of Swing are based in floating point numbers, but JSliders are based in integers.Thus, the dynamic range of the JSliders is typically many orders of magnitude away from the dynamic range of the spinners.Even worse, changes in a numeric model can propagate to an integer-based spinner.This leads to quantization error and back propagation of the re-quantized value.Interactive programs use multiple viewers and controllers to alter an underlying numeric model.These can update each other in an observer-observable loop that can propagate unintended and unmanaged digitization errors.The OCO design pattern breaks the loop and maintains control of the numerical values.The interception of changes is done via a modification of the equals method.If two numbers are equal (to within a user defined tolerance) propagation is suppressed.Thus, the digitizer re-samples and re-quantizes the numeric event.Another potential problem arises when multiple viewer-controllers for the same number model employ differing scales.For example, sliders can range between two integer numbers (e.g., 0...100); whereas the floating-point number that we would like to model ranges from 0.0 and 1.0.We demonstrate a procedure for translating one value into the range of another, without error or feedback.OCO also samples events in time.This band limits the events to a level deemed reasonable for the application.

Read the paper · More papers on PaperTik