REAL-TIME UI UPDATION – PUSH VS PULL METHOD

INTRODUCTION

In the real world scenarios where applications with a heavy number of concurrent users, status figures displayed in the user interface of the application need to be updated frequently. Instant decisions taken online which affects the business calculations like stock exchanges rely a lot on the availability of up to date information in front of the user.

This document describes the two different approaches can be taken to implement real time data updating in the user interface where complex controls are used. We’ll be using the example of a tree control in a Work Flow Management Application, which represents in their nodes, teams, categories, work items and its status information both in numbers and colors.

Team Leads, Managers and other stakeholders of the Business needs to know the status of work items worked on at any instance. Lead Leads are more concerned about individual work items according to its severity and priority and also the performance of each individuals working under him. He may also need to know the instant status of the number of items worked on for that particular day or week. Whereas stakeholders like Managers and other decision making Business Executives would like to know the status of the performance of individual teams, streams or the whole company at any instance. Looking at the screen, they should be able to navigate the tree control to see the status of Team, Individuals and Work items or Categories and Work Items. Each tree node has an associated number which tells the number of Work Items worked on that that moment. Color of the work individual items on the tree tells its status (green- complete, blue – worked on, red – yet to start, etc.). This information has to be updated each time a user creates a new item, open an item to work upon or submit the completion of an item.

PULL TECHNIQUE

This is the conventional method where the data is pulled out of the database and the status data to be displayed is processed either in the Business Layer or using a Stored Procedure. This has to be triggered either buy a refresh of the web page or while a post-back event.

ARCHITECTURE

In the pull technique, each time when the user interface has to be updated, data to be displayed has to be fetched from the database and processed using a procedure at the data base or at Business Layer. In our example, against each tree node which represents a team or category, we need to calculate the number of open items and update the node accordingly.

ADVANTAGES

In the pull technique when a stored procedure is used, there is no process overhead at the Business Layer. We do not require complex design architecture for the application. Most of the time, the logic at the Stored Procedure level is fairly straight forward and simple.

DISADVANTAGES

Data processing to display the date at the Business Layer or Stored Procedure has to be processed each time a post back is done from the UI for each user. This is a high overhead which will result in very bad implications at the response time, thus performance.

PUSH TECHNIQUE

Push technique uses the method of pushing the data to be displayed to the UI using an intermediate storage. In contrast with Pull Technique where a calculation is done each time a post-back is invoked and data is pulled into the UI.

ARCHITECTURE

Push Technique uses a temporary intermediate storage (preferably a simple table that can be bound directly with any controls), to store the least minimum data required to display in the UI. Each time a status change happens in the data tables, it fires a trigger which intern calculates the updated data for the display and updates the Intermediate tables.

ADVANTAGES

Response time will be low and thus high performance, coz this method eliminates the need of Data processing at the Business Layer or Data Layer on each post-back. Temporary table separates display status data from business data. Display Data Table is simple in structure and can be bound with any UI controls easily.

DISADVANTAGES

Need an extra intermediate table and trigger on each data table which updates the status counts. You need to keep the structure of Display Data Table and Display controls in sync.

ADVANCED TECHNIQUES

Using .Net 3.0 and LINQ (Language Integrated Query) where Triggers can be written in a C# library, using an event which can be fired on data updation at the table level can be listened and captured at the Business layer to propagate and update at the UI.

COMPARISON

Pull and Push Techniques caters the same need, but in different ways. Pull is simple and traditional which gives less efficient but simple way of UI updation. Whereas Push technique uses an intermediate table to differentiate Data Tables from Display Data. Triggers on top of the Data Tables helps in updating the Display Table only when an update has happened on the status data.

TAIL-PIECE

Advanced SQLServer projects in .net 3.0 can be used as an alternative to TSQL Triggers, and thus invoking a real time update at the UI level. MVC works rather in a more code centered way where data processing happens every time, resulting in less efficiency.

Note: Document was prepared in a concise manner to reduce extended reading.