GUI Application Framework Architecture
Introduction
Today in the software industry, great success has been archived in the graphical user interfaces (GUI) development. However, the main efforts for instrumental tools for developers are concentrated in a field of visual control libraries and visual GUI designers.
Such tools have a great influence in increasing software development productivity. However, developers still frequently have to solve similar tasks like: to share work between several programmers, to develop flexible module applications or use ready code. Most of the existing development tools are very low level to help in such problems.
The developed GUI Application Framework (GAF) is an attempt to solve these problems. The framework is based on using component models (such as Java Beans or ActiveX) and does not limit developers with tools and approaches in software design. It can be described in terms of Design Patterns. For better understanding of the main concepts, a comparison between TeX and LaTeX systems is presented below.
TeX is a powerful published system created by Donald Knuth. It's perfect but too complex for everyday usage. To simplify the work the LaTeX system was created as a set of ready to use templates to the TeX. With it’s help users can make more than 90% of all the tasks. But if the user meets something nonstandard he/she has a chance to go down to the TeX and change any part of the LaTeX template or even create a new one. The interesting feature of the LaTeX templates is that they are created by the best specialists and have a very professional design. Changes of LaTeX templates is not a simple task, thus beginners frequent do not wish to spoil a thought-out standard view of a document.
Designing the GAF we tried to solve the following tasks:
Implement a set of adjustable templates for typical GUI applications.
Develop application as a set of user defined modules without high cohesion with main form and other modules. The advantages of this approach are:
An application is ready from the start of development even though there are no implemented modules. During the development process the application obtains a new functionality step by step and it’s ready to work all the time. Professional developers know that managers always want to know the project progress and some conscientious customers would like to participate in the development process. But using traditional approach very frequently an application has only two stages: ready on not ready and the development period is covered by darkness.
There are some overlaps and related problems when several developers work on the same project simultaneous. Changes made by one programmer to the code can lead to other programmer’s code working incorrectly or can’t even be compiled. Module development in the GUI Application Framework isolates separate pieces of code and provides communication only through stable standard interfaces
There is a lot said in modern software industry about reusing ready code. But in practice, reusing ready code becomes a more difficult task because different pieces are implemented with high cohesion. Mostly reusing ready code is possible due to disciplinary of designers and programmers but is not solved in frames of programming technologies. Information isolation of modules in GAF helps to simplify this task.
Perform dynamic activation modules inside application in runtime. With this feature the functionality can be changed on a customer’s place. One module can be replaced with another one without any coding. Similar approach was implemented in some commerce systems and is called “plugins”. However absolutely module applications are rarity today.
Increase reliability of client software. Due to information isolation of application modules we have an opportunity to run them in special containers analogically to modern Application Servers. Container takes the duty to provide a fail over safe for a module. In the process of handling of catastrophic errors, the container can restart the module. The client application does not crush in this case. Separation of module and resources and resource pooling also decrease system loading.
Modern applications attempt to solve maximum of users’ tasks providing similar software tools. GUI Application Framework contains a set of standard modules such as text editor, calculator or HTML-browser. Programmer can easy enrich his application adding there these standard modules.
System Achitecture
The main implementation ideas of the GAF are:
A main form is a basic connection link of an application. It presents a main graphical frame of an application and contains three big object groups: Visual Components (MenuBar, ToolBar or StatusBar), System Services (Modules Manager, Configuration Manager, Resource Manager, Messaging Service, etc) and Application Modules.
Visual Components define a specified Look & Feel of the main form and a type of graphical user interface.
System services provide basic functionality for application modules, resources management, security and module communication features.
Application modules are loaded and stored in a special service – Module Manager. In runtime they are activated in specific place of the main form implemented by Desktop component, and inserted into event processing cycle.
Main form provides to each module a special object – Module Context. Through this object module access the main form, their visual components and services as well to other modules.
Module lifecycle is implemented by Module interface. This is a single mandatory interface for module implementation. Other module interface can be supported to perform some specific actions.
Application modules are absolutely independent from each other as well as from the main form. Connection to the main form is provided by Module Context. Connection to other modules is performed through special system services which share resources (ResourceManager, ConnectionPool) or send messages (Messaging Service).
The above UML diagram describes the main GAF components and a place for user application classes. Components with similar functionality are grouped together in the diagram.
Main Form. The form implements base application functionality. It contains visual components and system services. According to programmed logic, it activates user-defined modules and attaches them to event processing cycle. Any module can access the contents of the main form through interface AbstractForm.
Module Context is the main connection point between module and the rest system. Through this context the module gets an access to components and services of the main form, reads resources and sends messages to other modules.
Visual Components of the main form consist of Main Menu, ToolBar, StatusBar, Desktop and so on. All the components except desktop are facultative and can be added according to user tasks. Moreover user has an opportunity to implement personal components and replace standard components with them.
System services are included to provide necessary services to user defined modules. For example: ModuleManager loads modules in background task, DebugManager provides centralized output for debugging information, ResourceManager provides centralized access to application resources such as images, strings and MessagingService handles communication between modules sending messages back and fore, etc.
Note that the standard main form does not create any components or services. It just contains a centralized storage and provides an access to them. The components and services creating is a tasks of user defined classes inherited from MainForm or a part of XML configuration file if special XML based components are used.
An application GUI strongly depends on specified Desktop component. So SdiDesktop implements SDI application view, MdiDesktop implements MDI application, OutlookDesktop represents Outlook like application with a special tasks panel and so on.
Module interfaces make possible a module life in the framework. Module is a single mandatory interface. It manages the module lifecycle. Due to this interface a module can be loaded, initialized and activated inside the main form. All other module interfaces are facultative and serve to perform special actions.
Components implemented by user. These components contain: (1) the main application form (it’s inherited from main form template class of directly from AbstractMainForm and has required contents) and (2) modules implemented application logic. Except for this components, user can redefine components and services of the main form and use them instead of standard ones.
Usage Example
Let’s look as the simple GAF example. It is a Java implementation of HelloWorld application.
The main application form inherited from AbstractMainForm:
import com.mmsi.intellimine.gaf.*;
import com.mmsi.intellimine.gaf.util.*;
public class HelloApp extends AbstractMainForm {
/**
* The user define module to load into application
*/
private String[] modules = { "com.mmsi.intellimine.gaf.test.HelloModule" };
/**
* Constructs this main form.
*/
public HelloApp() {
// Creates this main form using ready to use template
FeaturedMenuBar mainMenu = new FeaturedMenuBar(this);
// Adds to main menu bar menu File with item Exit
mainMenu.add(mainMenu.createShortFileMenu());
// Adds main menu to main form
putComponent(MAIN_MENU, mainMenu);
// Adds status bar to main form
putComponent(STATUSBAR, new SimpleStatusBar(this));
// Adds module loading manager and says to load our module
putService(MODULE_MANAGER, new ModuleManager(this, modules));
// Sets main window title
setTitle("Hello Application");
// Makes standard initalization of this main form
init();
}
/**
* Runs this main form as standalone application
*/
public static void main(String[] args) {
HelloApp mainForm = new HelloApp();
}
}
User defined module with elementary functionality:
import java.awt.*;
import javax.swing.*;
import com.mmsi.intellimine.gaf.*;
import com.mmsi.intellimine.gaf.module.*;
public class HelloModule extends JPanel implements Module {
/**
* Constructs this module
*/
public HelloModule(AbstractMainForm mainForm, Object container) {
}
/**
* Draws "Hello, World!" message on the contents.
*/
public void paint(Graphics g) {
g.drawString("Hello, World!", 10, 30);
}
/**
* Gets the component which will be buildin into main form
*/
public Component getClientPane() {
return this;
}
/**
* Gets a name of this module
*/
public String getName() {
return "My Module";
}
/**
* Gets a user name of group similar modules.
* @result a user-friendly name of module group.
*/
public String getGroupName() {
return "Test";
}
/**
* Gets an icon of this module.
*/
public Icon getIcon(boolean smallIcon) {
return null;
}
}
After compilation and running we can get an application with the next view:
The complete java implementation with examples and documentation
is available on the site
http://www.sourceforge.net/projects/comedia
Conclusion
The practice the GUI Application Framework usage showed the productivity of each GUI programmer can be increased up to 1.5-2 times by programming with ready to use templates and modules.
Moreover a group development and testing of large systems are simplified by full isolation of different programmers work. Managers and customers obtain an opportunity to participate in a system development and control the quality and functionality of the system from the start as well.
Frequently different customers require some minor changes in the software. Modular software helps to solve the problem with specific customer’s code, avoid parallel versions of software and significantly decrease tech support costs.