Guaranteeing Responsiveness and Consistency In
Total Page:16
File Type:pdf, Size:1020Kb
View metadata, citation and similar papers at core.ac.uk brought to you by CORE provided by Texas A&M Repository GUARANTEEING RESPONSIVENESS AND CONSISTENCY IN DYNAMIC, ASYNCHRONOUS GRAPHICAL USER INTERFACES A Dissertation by CHARLES GABRIEL FOUST Submitted to the Office of Graduate and Professional Studies of Texas A&M University in partial fulfillment of the requirements for the degree of DOCTOR OF PHILOSOPHY Chair of Committee, Jaakko J¨arvi Committee Members, Gabriel Dos Reis Paul Gratz Frank Shipman Head of Department, Dilma Da Silva May 2016 Major Subject: Computer Science Copyright 2016 Charles Gabriel Foust ABSTRACT This dissertation proposes a programming model for Graphical User Interfaces (GUIs) that relieves the programmer of a difficult and error-prone task: orchestrating concurrent responses to events to ensure data dependencies are always enforced correctly. In this programming model, rather than defining program responses to events, the programmer defines the data dependencies that exist in the GUI and the methods by which those depen- dencies may be enforced|a run-time system uses this specification to generate responses to events. The approach gives the following guarantee: the same sequence of events produces the same results, regardless of the timing of those events. The dissertation demonstrates the benefits of the proposed programming model with implementations of several example user interfaces. At the core of this programming model is a data structure known as a property model. A property model composes responses to individual events into a single reactive program that runs asynchronously. The program's results are used to update the GUI. The program is constructed in a manner that respects all data dependencies, thereby guaranteeing that results are consistent regardless of the length of time taken by individual responses. The core reactive program may be extended with features that support additional functionality, such as access to prior variable values, optional data dependencies, and identifying unused variables. The dissertation defines the semantics of the construction and execution of this reactive program formally. The dissertation shows how property models may be defined as a composition of reusable components. This is essential for modeling GUIs whose structures change in response to user events by the addition or removal of components. Components can con- tain data and dependencies as well as templates that describe how dependencies arise from composition with other components. Furthermore, templates can be written for arrays of components to define dependencies that arise among them. ii One key task of the property model is planning by which methods dependencies will be enforced. The dissertation describes how a specialized planner can be constructed that is able to create a plan for a specific property model. This specialized planner is essentially a Deterministic Finite-state Automaton (DFA), and can be orders of magnitude faster than a general-purpose planner. iii DEDICATION This dissertation is dedicated to my dear wife Shannon, whose constant love and support enabled me to work; and to my children Deborah, Brianna, Jonathan, and Melody, who were always ready to help me take a break. iv TABLE OF CONTENTS Page ABSTRACT . ii DEDICATION . iv TABLE OF CONTENTS . v LIST OF FIGURES . viii LIST OF TABLES . x LIST OF ALGORITHMS . xi 1. INTRODUCTION . 1 1.1 Motivation . 1 1.2 Approach . 5 1.3 Implementation . 8 2. BACKGROUND AND RELATED WORK . 9 2.1 MVVM . 9 2.2 Dataflow Constraints . 10 2.2.1 Multi-way Dataflow Constraints . 11 2.2.2 Hierarchical Multi-Way Dataflow Constraint Systems . 14 2.2.3 Dataflow Graphs . 15 2.3 Related Work . 17 3. THE CORE REACTIVE PROGRAM . 20 3.1 Solving the Constraint System Asynchronously . 22 3.1.1 Variables . 23 3.1.2 Methods . 23 3.1.3 Constructing the Reactive Program . 25 3.1.4 The Reactive Program Graph . 26 3.1.5 The Resulting GUI . 28 3.2 Operations and Commands . 30 3.2.1 Operations in the Reactive Program . 30 3.2.2 Operations as Commands . 35 3.3 Detecting Unreachable Program Elements . 36 3.4 Failure in an Activation . 38 v 3.5 Implementing Property Models with HotDrink . 40 4. EXTENSIONS TO THE CORE PROGRAM . 46 4.1 Accessing Prior Values . 46 4.2 Managing In-Place Modifications . 49 4.3 Optional Constraints . 53 4.4 Promise Forwarding . 56 4.5 Adjusting Variable Priorities . 58 4.6 Detecting Irrelevant Variables . 62 4.6.1 Contributing and Relevant Variables . 62 4.6.2 Creating the Evaluation Graph . 64 5. OPERATIONAL SEMANTICS . 67 5.1 About the Formalism . 67 5.1.1 Notational Conventions . 67 5.1.2 Symbols and Values . 68 5.1.3 Evaluation Environment . 70 5.1.4 The Callback Set . 72 5.2 The Evaluation Rules . 74 5.2.1 Editing the Property Model . 74 5.2.2 Scheduling Methods . 76 5.2.3 Variables and Promises . 80 5.2.4 Promise and Edge Usage . 81 5.2.5 Lifting Functions . 85 5.3 Summary . 86 6. COMPONENTS AND DYNAMIC ELEMENTS . 87 6.1 Components and Composition . 89 6.2 Templates and Dynamic Elements . 92 6.3 Templates as Signals . 96 6.3.1 Signals . 96 6.3.2 Labels . 97 6.3.3 Paths . 98 6.3.4 Templates . 99 6.3.5 Resulting Elements . 100 6.3.6 Implementation . 101 6.4 Dynamic Elements Using Arrays . 102 6.5 Array Components as Signals . 105 6.5.1 Array Components . 105 6.5.2 Indexing Expressions . 106 6.5.3 Paths . 108 6.5.4 Templates . 110 6.5.5 Resulting Elements . 111 vi 6.5.6 Implementation . 111 6.6 Signature Variations . 112 6.6.1 Constants and Partial Instantiation . 113 6.6.2 Nested Signatures and Array Slices . 115 6.7 Proper Placement of Property Model Modifications . 118 7. STATIC ANALYSIS: SPECIALIZING PLANNERS . 121 7.1 Supplementary Background Material . 122 7.1.1 Planning Algorithms . 122 7.1.2 Constraint Systems as a Monoid . 123 7.1.3 Planning of Constraint Hierarchies as Monoid Composition . 126 7.2 Properties of Constraint Compositions . 128 7.3 Specializing a Constraint System . 129 7.3.1 Planner as a DFA . 130 7.3.2 Generating the DFA . 131 7.4 Experiments . 136 7.4.1 Generator Implementation . 136 7.4.2 Methodology . 139 7.4.3 Results . 142 8. CONCLUSION AND FUTURE WORK . 149 REFERENCES . 152 APPENDIX A. LISTING OF OPERATIONAL SEMANTICS . 159 A.1 Overloaded Signatures . 159 A.2 Evaluation Environment . 160 A.3 Editing the Property Model . 161 A.4 Scheduling Methods . 162 A.5 Variables and Promises . 164 A.6 Promise and Edge Usage . 165 A.7 Lifting Functions . 167 vii LIST OF.