Web Development with TIBCO General Interface: Understanding General Interface Architecture
One of the strengths of General Interface is its capability to work with XML and XSL. All widgets use XML/XSL to render the component onscreen. JavaScript is used for handling user actions. This strategy helps General Interface applications run faster than JavaScript code in the browser because the XSL processor used by the browser runs at high speeds, whereas the JavaScript processor runs outside the browser and must first be compiled every time and then executed. Additionally, GI Builder—the interactive development environment (IDE) that's included with TIBCO General Interface—makes it possible to visually build prototypes very quickly using more than 100 ready-to-use widgets from a component palette.
Applications that are built with General Interface should take advantage of General Interface's architecture for best performance. It is possible to build applications entirely in JavaScript using the framework APIs; however, the performance of JavaScript is about 10 times slower than that of XML/XSL processing. Therefore, it is important to understand how General Interface works and exploit it in building applications to get the highest levels of performance. General Interface's architecture includes many ways to use XSL processing to improve performance. TIBCO General Interface's JavaScript framework includes numerous classes and methods to load, cache, and parse XML documents as well as transform documents using XSL style sheets at runtime.
Model View Controller Architecture
Model-View-Controller (MVC) is a proven pattern for building graphical user interfaces since Smalltalk-80. GUI frameworks, such as Microsoft Foundation Classes (MFC), Java Swing, WinForms, and Struts for Java-based web applications, all use the MVC pattern. This pattern offers some key benefits to GUI developers: First, it modularizes the code and breaks a large problem down to many smaller ones and allows for faster team development. It also makes the code much more maintainable because each part of the code is dealing with its own set of variables and behaviors. One of the most important advantages of using MVC for GUI frameworks is that it makes the framework easily expandable and customizable. For example, it becomes possible to extend a View class to create a customized view. Multiple views can be attached to a single model if needed. Views can also use the observer pattern to update themselves when the model changes.
In an MVC pattern, three primary classes are involved: a Model class that owns the internal state of the data that drives the view, a View class that owns what is displayed on the screen and has direct access to make changes to it, and a Controller class that orchestrates user actions. When a user clicks a button, it is first felt by the corresponding View class. It then immediately passes it along with any parameters necessary to the Controller class. Logic to handle this click is in the Controller class, which performs the necessary steps and updates the Model class if necessary. The Model class then notifies the View class that something has changed, and the View class then picks up the new data and updates the display accordingly.
This architecture opens up the possibility for actions coming from anywhere—for example, a back-end process could invoke an action on the Controller to deliver a message that needs to be displayed to the user. Multiple different View classes can be associated with the same model to display the data in a different representation. For example, a Model class that represents tabular data could be displayed via two independent views—one that shows a grid onscreen and another that shows a chart from the same data. Figure 2.1 shows a high-level representation of the MVC pattern in use.
Figure 2.1 High-level representation of MVC.
All controls and widgets in General Interface use XML as data and are driven by a combination of XSL style sheets and JavaScript code. General Interface defines a format called the Common Data Format, or CDF, which is a form of XML. General Interface also includes a large collection of XSL style sheets that transform the backing CDF into HTML elements such as grids, lists, and menus. JavaScript code that orchestrates the behavior of the widgets is structured in packages, classes, and interfaces. General Interface follows a style similar to the Prototype framework for JavaScript code to define interfaces and classes that support object-oriented concepts of inheritance, polymorphism, and encapsulation. This style makes JavaScript code look almost like Java code. However, keep in mind that JavaScript is not a true object-oriented language, and therefore not all the features of a modern language such as Java or C# are available to developers.