Asynchronous View Model Data Retrieval
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
The traditional Model-View-Controller (MVC) pattern in object-oriented programming faces challenges when data needed by the model and/or view is not readily available, particularly in scenarios where data retrieval from network sources is involved, leading to delays in user interface responsiveness.
Innovation Solution
The implementation of an asynchronous data request mechanism where a view model receives a data request from a view, makes asynchronous requests to a data model, and returns a promise to the view, allowing the view to update when data becomes available, decoupling data retrieval from the user interface and enabling caching to reduce network requests.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If synchronous data retrieval is used in the traditional MVC pattern, then data is obtained from network sources, but the user interface becomes unresponsive during data retrieval
Solution Approach 1:
The system initiates data retrieval operations in advance using asynchronous requests, allowing the user interface to be prepared and displayed before the actual data is received from network sources. This preliminary action prevents the UI from waiting idle during data retrieval.
Solution Approach 2:
An asynchronous data retrieval mechanism is introduced as an intermediary between the user interface and the data source. This intermediary handles the data retrieval process without blocking the UI thread, using callbacks or promise-based patterns to deliver data when ready.
2Measurement precision
If data retrieval operations are performed synchronously, then data accuracy is ensured, but the application execution speed decreases
Solution Approach 1:
Data retrieval is initiated in advance through asynchronous operations, allowing the application to continue executing other tasks while waiting for data. This preliminary action maintains data accuracy through proper error handling while improving overall application execution speed.
Solution Approach 2:
The system dynamically switches between synchronous and asynchronous operation modes based on the specific data retrieval context. Critical data operations maintain synchronous accuracy, while non-critical operations use asynchronous patterns to improve execution speed.
3Stability of the object's composition
If the view model directly queries the data model for data, then data consistency is maintained, but the view cannot be created until data is available
Solution Approach 1:
The view model is instantiated and the view is created in advance, even before data is available from the data model. Asynchronous data retrieval is initiated simultaneously, and the view is updated once data becomes available, eliminating the need to wait for data before view creation.
Solution Approach 2:
An asynchronous data retrieval mechanism acts as an intermediary between the view model and data model, allowing the view to be created independently and updated later when data is retrieved, thus decoupling view creation from data availability.
4Measurement precision
If network requests are made for each data retrieval, then real-time data is obtained, but network bandwidth is consumed excessively
Solution Approach 1:
Multiple data retrieval requests are merged into a single network request where possible. The system consolidates data needs and retrieves data in batches or using shared connections, reducing the total number of network requests while maintaining real-time data accuracy through efficient data caching and sharing.
Solution Approach 2:
The system performs preliminary data retrieval to obtain data in advance, caching it for subsequent use. This preliminary action reduces the need for repeated network requests while maintaining data real-time accuracy through intelligent caching strategies and cache invalidation protocols.
Data Source
Figure 1
Figure 2A~2B
Figure 3
AI summary
The described technology is directed towards asynchronous models that retrieve view-specified data for a view. A view requests a view model to return view-specified data; in turn, the view model makes one or more requests to a data model to retrieve information corresponding to the view-specified data. The data model communicates with a data source such as a web service or a cache to return the requested information to the view model. The view model may assemble / reformat the information into a data format corresponding to the view specified data format for returning to the view. The requests may be asynchronous, with a promise returned in response until the data or information is returned to fulfill the promise.