A Light-Weight Broker for GUI Applications


Hironori Washizaki, Junko Shirogane and Yoshiaki Fukazawa

{washi, junko, fukazawa}@fuka.info.waseda.ac.jp


Waseda University
3-4-1 Okubo, Shinjuku-ku, Tokyo, 169-8555, Japan


ABSTRACT
Many GUI application components are developed by means of RAD tools, which are based on the WYSIWYG philosophy. These tools can realize the partial separation between GUI and application logic part, however, class-file- level separation between them cannot be realized enough. We propose a fully separated software architecture called "BeaM", which contains not only event model from GUI to application logic part but also an acknowledge model from application logic part to GUI. In order to realize full separation, a broker which mediates GUI and application body is proposed.

INTRODUCTION
The targets of the domain-oriented software development technology can be classified to two types. One is the vertical domain, which is application specific. The other is the horizontal domain, for example, GUI, database transaction or collaboration. In this paper, we propose an approach to separate GUI part and logic part of GUI applications in the GUI application domain and combined them by a light- weight broker.

GUI application components, which are specified to a particular domain, are often reused. They are developed by linking most low-level generic components and by adding transaction logic part to them in developing an application [1]. Such GUI application components are developed by means of RAD tools [2] (For example, JBuilder2.0 and so on) based on the WYSIWYG philosophy. In these components, GUI and application logic part (In this paper, we abbreviate ALP [3]) depend on each other and exist together in a class-file. Therefore, independence of GUI and ALP is partially obtained, so the merits of maintainability and reusability on component-based application may are decreased.

GUI application components, which are developed by means of RAD tools, have adapters for events from GUI (Delegation event model [4]), and connected with ALP written by developers (Figure 1). In this figure, ALP is independent of event notification from each GUI, but ALP refers GUI directly. In the result, following problems have occurred:

Maintainability and extensibility:
In GUI components, it is necessary to modify not only an adapter but also ALP, because ALP refers GUI directly. They are included in a class-file together and it is difficult to find a point to modify, so the cost grows costs for extension or maintenance.

Difficulty of parallel development:
GUI and ALP can not be independent because they refer each other, so developers can not develop GUI and ALP for an application in parallel.

In order to resolve such problems, we propose an architecture BeaM (Bean for MVC). BeaM is an additional architecture for JavaBeans and can apply MVC [5] pattern completely to internal structure of GUI application components in developing. Concretely in BeaM, GUI and ALP do not depend on each other by adopting not only event model from GUI to ALP but also an acknowledge model from ALP to GUI.

BEAM ARCHITECTURE
Summary of architecture
BeaM components can be categorized into three kinds of objects: Container, Model and UI (Figure 2).

Container object: Container objects generate Model objects and UI objects, and also mediate between data and event notification between them. It is implemented by inheriting the BeaMContainer class.
The Container object has a name table internally. Therefore this can be considered as a kind of Broker [6].

Model object: Model objects have data, its operation and reference to the Container objects. These objects have the BeaMModel interface.

GUI object: UI objects interact with users through GUI and refer Container objects. These objects have the BeaMUI interface.

Link between Model and UI
A container object mediates all of communication between Model objects and UI objects in order to keep independence of each other (Figure 3).

Data sharing: Application developers determine data in Model objects shared with UI objects in the design phase. BeaM can supplies an automatic mechanism for data sharing along with Observer pattern [5], where a Model object plays "Observable" and a UI object plays "Observer". Shared data and its data-names for the Model objects are registered initially in the data-table of the Container objects, and noticed to the UI objects automatically when the value is changed. The UI objects take out the value using the data-name for the UI object from the Container object, and pass it to GUI (Figure 4).

Internal event transaction: Internal events are transferred from a UI object to a Container object with an identifier (event-name) for the event and data-name on GUI components to get. Our architecture gets input data from a GUI component on a UI object using its data-name at first, and then shared data are updated automatically. After that, a required operation for the event-name are performed to a Model object defined previously (Figure 5).

An external behavior for a JavaBeans component is realized as access transfer to properties of a Model object or a UI object from external and event notification to external via a Container object.

INTEGRATED DEVELOPMENT TOOL BEAMBUILDER
A tool, in which BeaM components can be developed along with BeaM architecture visually, is required because components are generally integrated visually using RAD tools which are based on the WYSIWYG philosophy [7]. BeaMBuilder is a tool for developing BeaM components. ModelBuilder (for Model), UIBuilder (for UI) and Integrator (for Container) in BeaMBuilder give functions for each kind of objects. Figure 6 shows this development model.

ModelBuilder: ModelBuilder helps developers to develop Model objects. Developers determine a data-name for a Model object with shared data in data definition. ModelBuilder generates necessary program codes for data sharing and store the information about shared data in ModelInfo objects.

UIBuilder: UI objects can be designed visually using UIBuilder. Developers declare to keep watch on shared data in Model objects using data-name for UI. UIBuilder generates necessary program code for data sharing. Internal events are defined after event-names are defined for events from GUI. The information about shared data and internal event are automatically stored in UIInfo objects.

Integrator: Using this, developers can get the information about shared data from ModelInfo and UIInfo, link shared data to Model objects and UI objects visually, and describe transaction for noticing an internal event from UI objects. Based on these operation, Integrator generates the codes for Container class (ConcreteBean class in Figure 2) and stores properties and events to show as JavaBeans components, in BeanInfo objects.

EXAMPLE OF DEVELOPMENT AND ITS EVALUATION
Through an example, we will show the method for developing GUI application components based on the BeaM architecture by BeaMBuilder, and also the advantages for correction and extension against existing methods. We adopted JBuilder2.0 [8] of Inprise Corporation as a comparative target.

LoginFormBean along with JavaBeans framework is a Bean of which functions in AuthenticatorBean [9] are simplified. LoginFormBean is used for entering ID and password. It has an id and a password as the property, and its access methods are made public (Figure 7).

Detailed customization in each component
We changed JTextField for password to JPasswordField, and JtextField for ID to JComboBox.

In the existing method, for such modification, developers must modify access methods for the properties of id and password (Figure 8). These access methods are not modified in changing the design of GUI. In the result, it becomes difficult to customize GUI or ALP in each. If BeaMBuilder is used, developers only determine the data- name (UIDataName) same as before changing by UIBuilder, and they do not have to modify Model objects for ALP at all. Developers can visually determine data- name for the property of each GUI component by UIBuilder, so it is easy to change GUI application components.

public void setPassword(String password) {
this.password = password; // set a new value
// update the output to GUI
jPasswordField1 setText(password);
}

public void setId(String id) {
jComboBox.setSelectedItem(id);
if (!jComboBox.getSelectedItem().equals(id))
jComboBox.addItem(id);
this.id = id;
}
    Figure 8: Existing methods: modification of GUI parts

In Figure 9, we compared JBuilder2.0 with BeaMBuilder about the number of modified lines in these change. Based on these results, using BeaMBuilder, developers may need to modify linking definition in Container objects in changing and modifying the one GUI. However, because linking definition is independent between Model objects and UI Objects, developers do not have to modify the other objects.

Coordination of output data
Referring above, property "password" has to update not only for direct input from users to GUI but also for other input from system in LoginFormBean.

If applications are carefully designed for interaction between internal data of components and output to GUI, this problem can be avoided. However, developers do not have to take care of coordination between Model objects and UI objects about shared data. Because UI objects always keep watch the status of shared data.

Multiple Views for ALP
In existing methods, the ways for providing multiple GUIs for ALP in application components are only follows: developers have to change the description of transaction for putting out to GUIs in application components, or make GUI and ALP independent and register another components, which put out data to multiple GUIs, as an event listener for changed data. For example of LoginFormBean, developers have to add the lines such as Figure 10 in adding new output to GUI. However, it is necessary to modify to receive the updating result on another shared data, so it costs too much both to find programming codes to modify and modify appropriately

public void setPassword(String password) {
this.password = password;
// existing output to GUI
jTextField2.setText(password);
// add new definition of output to GUI
logIndex++;
logTextArea.append(logIndex + ">" + password);
}
    Figure 10: Existing methods: adding new output to GUI

If those components are BeaM components, unique Model object is not necessary to aware of the existence of UI objects and notify automatically updating message. Therefore, developers can define multiple UI objects easily. For example of LoginFormBean, in case of adding output to GUI similarly, developers can only develop new UI objects, and change (add) shared data and linking definition of internal event in LoginFormBean (Figure 11).

public class LoginFormBean extends BeaMContainer {
public loginFormBean() {
super();
// binding data name
addDataName("Login_PASSWORD", "PASSWORD_Text");
LoginFormUI ui = new LoginFormUI((BeaMContainer) this);
// adding new output to GUI
LogTextAreaUI logui = new LogTextAreaUI((BeaMContainer) this);
setBeaMUI((BeaMUI) ui);
setBeaMUI((BeaMUI) logui);
}
}
    Figure 11: BeaMBuilder: adding new output to GUI

Addition of new UI objects to existing BeaM components with necessary linking definition can be performed visually and easily using BeaMIntegrator.

In Figure 12, we compared JBuilder2.0 with BeaMBuilder about the number of modified lines in above adding GUI. From these results, using BeaMBuilder, the Model object and the UI object are not directly aware of each other and the Model object, only one object in a component, can depend on multiple UI objects via Container objects. Therefore, it is easy to plug GUIs dynamically, or display same data to multiple GUIs at the same time.

Runtime Performance
Applying BeaM architecture to GUI applications, the runtime performance becomes lower instead of reusability. To evaluate the degradation of the performance, we measured the execution time by automatically repeating the fixed number of sequences of actions, i.e. entering values, firing LoginEvent and clearing the values. The result is shown in Table 1. Referring this, the difference is comparatively small, so BeaM has no performance problem for practical usage.

OFF Screen ON Screen
Loop[times] Old[ms] BeaM[ms] Old[ms] BeaM[ms]
100 560 651 2954 3764
1000 2103 2804 11997 17134
10000 20592 28871 194826 283467
(Sun JDK1.2.2, WindowsNT4.0 Server, 500MHz/PentiumIII, Memory 256M)

CONCLUSION
In case of developing GUI application components along with BeaM architecture, the information of data to be shared and internal events are required in developing Model objects and UI objects. Therefore, it is necessary to consider about what kind of compound components including GUI is important, and ALP should be included.

In BeaM components, all of internal data are mediated via Container objects, so the performance becomes clearly worse than the components, which ALP and GUI depend on each other. But, by our evaluation, this rate is comparatively small. Therefore, our approach for Light-Weight GUI Broker is effective in practical usage.

We have to inspect how much application developers can get the effects of lowering costs with correcting and extending.

References
1. R. N. Taylor and G. F. Johnson: Separations of Concerns in the Chiron-1 User Interface Development and Management System. Proceedings of INTERCH'93, pp.367-374, 1993
2. D. McMahon: Rapid Application Development with Visual Basic 6 (Enterprise Computing). McGraw Hill, 1999.
3. The UIMS Tool Developers Workshop: A Metamodel for the Runtime Architecture of an Interactive System. SIGCHI Bulletin Vol,24, No.1, pp.32-37, 1992
4. G. Hamilton: JavaBeans 1.01 Specification. Sun Microsystems, 1997.
5. E. Gamma, R. Helm, R. Jphnson and J. Vlissides: Design Patterns. Addison Wesley, 1995.
6. R. Orfali, D. Harkey and J. Edwards: The Essencial Distributed Objects Survival Guide. John Wiley & Sons, Inc., 1996.
7. R. Englander: Developing Java Beans, O'Reilly, 1997.
8. Inprise: Borland Jbuilder. Available at http://www.borland.com/jbuilder/.
9. Sun Microsystems: HotJava HTML Component. Available at http://java.sun.com/products/hotjava/bean/.