Development and evaluation of a low-level plugin ... - OpenJEVis
Development and evaluation of a low-level plugin ... - OpenJEVis
Development and evaluation of a low-level plugin ... - OpenJEVis
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
HAMBURG UNIVERSITY OF TECHNOLOGY<br />
INSTITUTE FOR SOFTWARE SYSTEMS<br />
<strong>Development</strong> <strong>and</strong> Evaluation <strong>of</strong> a <strong>low</strong>-<strong>level</strong><br />
Plugin Framework for Data Analysis <strong>and</strong><br />
Visualisation Applications<br />
Bachelor Thesis by Benjamin Schwanke<br />
Hamburg, 2nd May 2010<br />
Supervisor:<br />
Advisor:<br />
Company Supervisor:<br />
Pr<strong>of</strong>. Dr. Sibylle Schupp<br />
Dipl.-Inform. Rainer Marrone<br />
Dr. Stefan Kuck
Declaration<br />
I hereby confirm that I have authored this thesis independently <strong>and</strong> without use <strong>of</strong> others<br />
than the indicated resources. All passages taken out <strong>of</strong> publications or other sources are<br />
marked as such.<br />
Hamburg, 2nd May 2010<br />
City, Date<br />
Sign
Acknowledgements<br />
I sincerely would like to thank Pr<strong>of</strong>. Dr. Sybille Schupp for giving me the opportunity to<br />
perform this interesting <strong>and</strong> challenging work in her department. Special thanks to Dipl.-<br />
Inform. Rainer Marrone for his support, motivation <strong>and</strong> for many helpful discussions. My<br />
other special appreciation goes to the management <strong>of</strong> the Envidatec GmbH, specifically to<br />
Dipl.-Ing. Thomas Frank, Dr. Stefan Kuck <strong>and</strong> Pr<strong>of</strong>. Dr. Peter Palensky for providing me<br />
with the challenge to carry out my research work within the company. Last but not least,<br />
I want to express my gratefulness to my family <strong>and</strong> friends for their support during the<br />
making <strong>of</strong> this thesis <strong>and</strong> the whole study.
Abstract<br />
The advantage <strong>of</strong> visualising data stems from its ability to make use <strong>of</strong> the human’s efficient<br />
perceptual system. For that reason s<strong>of</strong>tware with easy to use graphical user interfaces<br />
<strong>and</strong> comfortable features to display a wide range <strong>of</strong> different data becomes more important.<br />
This project deals with a design <strong>of</strong> a <strong>low</strong>-<strong>level</strong> framework providing extensibility for a<br />
main s<strong>of</strong>tware construct through addable <strong>plugin</strong>s based on existent prerequisites. Different<br />
approaches are evaluated <strong>and</strong> the reasons for chosen concepts are given.<br />
Kurzfassung<br />
Visualisierte Daten haben den großen Vorteil, dass diese vom Menschen weitaus besser<br />
wahrgenommen und behalten werden, als Daten, welche in unformatierter Form vorliegen.<br />
Aus diesem Grund kann der Entwicklung von S<strong>of</strong>tware mit leicht zu bedienenden<br />
grafischen Benutzeroberflächen und intuitiven Funktionen zum Darstellen von verschiedensten<br />
Daten eine große Bedeutung zugesprochen werden. In dieser Arbeit wird ein<br />
einfaches Framework entwickelt, welches die Möglichkeit bieten soll, ein Kernprogramm<br />
durch Plugins zu erweitern. Dabei sind gewisse Vorgaben einzuhalten. Die verschiedenen<br />
Ansätze werden bewertet und Gründe für benutzte Konzepte aufgezeigt.
Contents<br />
1 Introduction 1<br />
1.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1<br />
1.2 Structure <strong>of</strong> the Thesis . . . . . . . . . . . . . . . . . . . . . . . . . . . 2<br />
2 Background 3<br />
2.1 Current Visualisation Concepts . . . . . . . . . . . . . . . . . . . . . . . 3<br />
2.1.1 Present GUIs <strong>and</strong> Applications . . . . . . . . . . . . . . . . . . . 3<br />
2.1.2 S<strong>of</strong>tware Specification . . . . . . . . . . . . . . . . . . . . . . . 4<br />
2.1.3 IBM ILOG JViews Charts . . . . . . . . . . . . . . . . . . . . . 4<br />
2.2 Plugin Approaches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5<br />
2.2.1 Hard-coded Plugins . . . . . . . . . . . . . . . . . . . . . . . . . 6<br />
2.2.2 Dynamic Plugins . . . . . . . . . . . . . . . . . . . . . . . . . . 7<br />
2.2.3 Discussion on existing Plugin Designs . . . . . . . . . . . . . . . 7<br />
3 Design <strong>and</strong> Implementation 9<br />
3.1 Design Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . 9<br />
3.2 Overview <strong>of</strong> the Framework Design . . . . . . . . . . . . . . . . . . . . 10<br />
3.3 Introducing the Plugin Architecture . . . . . . . . . . . . . . . . . . . . 11<br />
3.3.1 Interface vs. Abstract Classes in Project Context . . . . . . . . . 11<br />
3.3.2 Presentation <strong>of</strong> the Plugin Hierarchy <strong>and</strong> Configuration . . . . . . 12<br />
3.3.3 Extending the Framework with new Plugins . . . . . . . . . . . . 13<br />
3.4 Register <strong>and</strong> add Plugins to the Application . . . . . . . . . . . . . . . . 14<br />
3.5 Data Reception through a dedicated API . . . . . . . . . . . . . . . . . . 16<br />
3.6 Data Management <strong>and</strong> Interchange within the Framework . . . . . . . . . 16<br />
3.6.1 Configuration <strong>of</strong> the PluginData Class . . . . . . . . . . . . . . . 17<br />
3.6.2 Notification <strong>and</strong> Reaction to Changes in the PluginData Object . . 17<br />
3.7 Tools <strong>and</strong> Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18<br />
3.8 Suggestions how to increase Testability . . . . . . . . . . . . . . . . . . 19<br />
4 Conclusion <strong>and</strong> Outlook 22<br />
Bibliography 23<br />
List <strong>of</strong> Figures 25
Chapter 1<br />
Introduction<br />
1.1 Motivation<br />
The Envidatec GmbH provides energy services <strong>and</strong> energy management. Their major<br />
business area is the regular collection <strong>and</strong> <strong>evaluation</strong> <strong>of</strong> energy consumption information<br />
<strong>and</strong> other energy data in customer’s properties. Visualising this data is an important <strong>and</strong><br />
challenging task. Therefore, an application to display all data <strong>and</strong> to make different data<br />
rows comparable, easy to analyse <strong>and</strong> benchmark is a fundamental need.<br />
Existent tools in the company are able to do this in a simple way, but they are very specific<br />
or rather inflexible, hard to change <strong>and</strong> to update. Furthermore, each tool needs an<br />
individual web service to communicate with. That implies high-maintenance s<strong>of</strong>tware <strong>and</strong><br />
consequently much effort for s<strong>of</strong>tware engineers <strong>and</strong> programmers. A new system has<br />
been designed by the company to simplify <strong>and</strong> improve these concepts. There is only one<br />
application programming interface (API) to communicate with the database. Programs do<br />
not need a special web service, they just use the existing API.<br />
The main purpose <strong>of</strong> this project is the design <strong>of</strong> a framework that provides easy development<br />
<strong>of</strong> <strong>plugin</strong>s with all the features needed for best possible visualisation <strong>and</strong> analysis<br />
conditions. Registered <strong>plugin</strong>s can be arbitrarily added to <strong>and</strong> removed from a JPanel<br />
component (hereinafter referred to as the main frame). The main frame serves as the<br />
global graphical user interface (GUI) window with global features that are available <strong>and</strong><br />
applicable for every <strong>plugin</strong>. Database communication, data up- <strong>and</strong> download should be<br />
managed by the API. Data exchange between the <strong>plugin</strong>s has to be consistent <strong>and</strong> intuitive.<br />
Technical requirements regarding the programming language <strong>and</strong> libraries are as fol<strong>low</strong>ing:<br />
The programming language is Java. The Java Foundation Classes (JFC), including<br />
the Swing libraries, are used for the GUI <strong>and</strong> the graphical visualisation tasks are h<strong>and</strong>led<br />
mostly by the IBM ILOG JViews Charts library.
Chapter 1 Introduction 2<br />
1.2 Structure <strong>of</strong> the Thesis<br />
The introduction describes the purpose <strong>of</strong> <strong>and</strong> the need for a s<strong>of</strong>tware design proposed in<br />
this thesis.<br />
Chapter 2 introduces the prerequisites for the application to be created <strong>and</strong> presents two<br />
approaches <strong>of</strong> <strong>plugin</strong> architecture.<br />
Chapter 3 explains the design <strong>and</strong> implementation <strong>of</strong> the <strong>low</strong>-<strong>level</strong> framework developed<br />
in this project. Section 3.2 gives a general overview <strong>of</strong> the framework’s functionality while<br />
section 3.3 <strong>and</strong> 3.4 describe the <strong>plugin</strong> architecture in more detail. The problem <strong>of</strong> data<br />
exchange, im- <strong>and</strong> export is discussed in section 3.5 <strong>and</strong> section 3.6. An <strong>evaluation</strong> <strong>of</strong> the<br />
tools <strong>and</strong> libraries is carried out in section 3.7.<br />
Chapter 4 presents the reasons for the concepts <strong>and</strong> design approaches chosen in chapter<br />
3. Besides, an outlook on further development deals with future <strong>plugin</strong>s <strong>and</strong> additional<br />
features that can be added to the current application.
Chapter 2<br />
Background<br />
As this project has been carried out by a request <strong>of</strong> the Envidatec GmbH, it is necessary to<br />
introduce the conditions regarding s<strong>of</strong>tware development inside this company. This chapter<br />
describes the prerequisites, e.g. specifications for new s<strong>of</strong>tware products, the already<br />
existent tools <strong>and</strong> different approaches to design <strong>plugin</strong> extensibility.<br />
2.1 Current Visualisation Concepts<br />
Most <strong>of</strong> the s<strong>of</strong>tware currently used in the company is written in Java. Especially GUI<br />
tools use this technology including the Swing libraries to provide the user, respectively<br />
the customer, with an easy to use graphical user interface. The company’s customers are<br />
used to a certain look <strong>and</strong> feel. Provided tools fol<strong>low</strong> common GUI design guidelines.<br />
For this reason further development has to pursue this st<strong>and</strong>ards to preserve a general<br />
identity <strong>and</strong> recognition value. The visualisation part, e.g. show charts <strong>and</strong> analyse data<br />
in arbitrary diagrams, has to be implemented by the use <strong>of</strong> the IBM ILOG JViews Charts<br />
library introduced in section 2.1.3. This is no drawback, but has to be noted to underst<strong>and</strong><br />
further proceedings.<br />
2.1.1 Present GUIs <strong>and</strong> Applications<br />
The Envidatec GmbH provides a range <strong>of</strong> tools to analyse <strong>and</strong> to display consumption <strong>and</strong><br />
energy related data. Most programs are designed to connect to a database while every<br />
program needs its own client-server connection. Accordingly, every tool needs a dedicated<br />
running servlet to connect to. On that account, there are existing visualisation tools<br />
that implement basic features, but still suffer from certain inflexibility <strong>and</strong> the need for a<br />
particular servlet. But these tools already implement some core features <strong>and</strong> methods, e.g.
Chapter 2 Background 4<br />
zooming interactions, that can be transferred to the new application <strong>and</strong> avoid unnecessary<br />
redevelopment.<br />
2.1.2 S<strong>of</strong>tware Specification<br />
The entire program should serve as an analysis tool for recorded energy data, e.g. energy<br />
consumption <strong>of</strong> the heating system in a supermarket <strong>and</strong> related data, e.g. outdoor temperature.<br />
These data are saved as data sets in a dedicated database. The task is to visualise<br />
these data sets. For instance this can be done in all kinds <strong>of</strong> charts, e.g. Cartesian charts or<br />
pie charts. Any other utilisation <strong>of</strong> the logged data has to be possible as well. Thus, data<br />
sets are available through a database <strong>and</strong> can be used in arbitrary ways. The program has<br />
no dem<strong>and</strong>s on how to use the data, but its main purpose is to visualise them.<br />
To realise variable ways to use the recorded data, it is necessary to design a flexible solution<br />
that is able to cope with many use cases. The approach for this project is a <strong>low</strong> <strong>level</strong><br />
framework supporting a main application that holds <strong>plugin</strong>s to extend its functionality <strong>and</strong><br />
features.<br />
These <strong>plugin</strong>s are equipped with database access through a unique API. Any further connection<br />
points to external sources apart from the one provided by the dedicated API are not<br />
supported. Furthermore, data exchange within the main frame <strong>and</strong> especially between the<br />
<strong>plugin</strong>s is a main feature <strong>of</strong> the program. Loaded data sets in one <strong>plugin</strong> have to be transferable<br />
to another <strong>and</strong> the other <strong>plugin</strong> must be notified or even updated automatically, if new<br />
data is sent to its data storage object. Another important feature is the synchronisation <strong>of</strong><br />
available charts. Editing <strong>and</strong> zooming actions in a <strong>plugin</strong>’s chart can affect other <strong>plugin</strong>’s<br />
charts. This feature requires an option to link <strong>plugin</strong>s among each other. The X-axes <strong>of</strong><br />
these charts have be to synchronised if intended. This behaviour has to be controllable by<br />
the user via easy an easily accessible interface.<br />
2.1.3 IBM ILOG JViews Charts<br />
IBM ILOG JViews Charts provides a powerful set <strong>of</strong> pr<strong>of</strong>essional Java chart components<br />
for use in graphical user interfaces. It delivers complete support for desktop <strong>and</strong> web-based<br />
charting with a full set <strong>of</strong> chart components in a single package. Displays <strong>and</strong> interactions<br />
are completely customisable, ensuring developers a wide range <strong>of</strong> programming possibilities<br />
[8]. Figure 2.1 shows a stock chart designed with IBM ILOG JViews Charts.<br />
JViews Charts is based on the Separable Model Architecture [9]. This architecture is a<br />
variant <strong>of</strong> the Model-View-Controller (MVC), an architectural pattern that separates three<br />
application areas: data (model), representation (view) <strong>and</strong> interaction (controller) [17].
Chapter 2 Background 5<br />
Figure 2.1: Example <strong>of</strong> a stock chart designed with IBM ILOG JViews Charts<br />
This pattern provides an isolation between data <strong>and</strong> its screen representations. The data<br />
model is completely open <strong>and</strong> extensible, al<strong>low</strong>ing it to connect with any other application<br />
component. Notifications are automatic <strong>and</strong> transparent. When the data model changes,<br />
views are updated; when the user interacts with views, the model changes. By means <strong>of</strong><br />
the Separable Model Architecture, the model manages the data or the values represented<br />
by the component, while the view manages the graphical representation <strong>of</strong> the model, <strong>and</strong><br />
h<strong>and</strong>les interaction on it [9].<br />
2.2 Plugin Approaches<br />
To start developing s<strong>of</strong>tware with <strong>plugin</strong> extensibility it is important to underst<strong>and</strong> the<br />
concept <strong>of</strong> <strong>plugin</strong>s. A <strong>plugin</strong> in terms <strong>of</strong> computing is a s<strong>of</strong>tware module that adds new<br />
features to a host application. Figure 2.2 illustrates the host application providing the s<strong>of</strong>tware<br />
main functions, services <strong>and</strong> interfaces. Plugins usually do not work by themselves,<br />
they depend on these services. The <strong>plugin</strong> characteristics combined with the services provided<br />
result in new features accessible via the main s<strong>of</strong>tware program. Several designs<br />
al<strong>low</strong> <strong>plugin</strong>s to be extended by <strong>plugin</strong>s. This approach requires further extension points<br />
for each <strong>plugin</strong>. There are different ways to develop a program with <strong>plugin</strong> extensibility.<br />
The decision for one <strong>of</strong> these ways depends on its requirements.
Chapter 2 Background 6<br />
Host Applicaon<br />
Plugin<br />
Services<br />
Interface<br />
Features<br />
Plugin H<strong>and</strong>ler<br />
Interface<br />
Figure 2.2: General <strong>plugin</strong> structure<br />
2.2.1 Hard-coded Plugins<br />
Hard-coding in terms <strong>of</strong> s<strong>of</strong>tware development describes a programming practise that embeds<br />
configuration or input data directly into the source code <strong>of</strong> a program. It is an analogy<br />
to hard wiring circuits to convey the inflexibility when used within s<strong>of</strong>tware implementation<br />
<strong>and</strong> design.<br />
Host Applicaon<br />
Services<br />
Hardcoded Plugin<br />
load <strong>and</strong><br />
communicate<br />
Features<br />
Plugin H<strong>and</strong>ler<br />
Figure 2.3: Hard-coded <strong>plugin</strong> structure in this project<br />
A hard-coded <strong>plugin</strong> in this project is referred to be a part <strong>of</strong> a program, that is implemented<br />
in the source code <strong>of</strong> the main application. This design is shown in figure 2.3. Every<br />
change in the <strong>plugin</strong>’s source code requires another compilation <strong>of</strong> the entire program. In<br />
return a hard-coded <strong>plugin</strong> structure provides a simple way to develop. Dynamic class
Chapter 2 Background 7<br />
loading <strong>and</strong> file access is not necessary. This feature is particularly beneficial for applet<br />
development, because according to the Java security manager, applets are subject to high<br />
restrictions on server <strong>and</strong> client file access.<br />
2.2.2 Dynamic Plugins<br />
A dynamic <strong>plugin</strong> structure is mainly characterised by a <strong>plugin</strong> development that is independent<br />
<strong>of</strong> the main application’s program code. Programmers are able to add <strong>and</strong> update<br />
<strong>plugin</strong>s to a host application dynamically without changing its source code. Many applications<br />
using this approach even provide <strong>plugin</strong> loading at runtime. Therefore, the <strong>plugin</strong>’s<br />
compiled files must be stored in a separate location, e.g. in Java they cannot be part <strong>of</strong> the<br />
main application’s Java Archive file (JAR).<br />
This approach raises the fol<strong>low</strong>ing requirements:<br />
• A more generic framework<br />
• A <strong>plugin</strong> discovery <strong>and</strong> loading component<br />
• Server-side read <strong>and</strong> write access when used in applets<br />
The design <strong>of</strong> a dynamic <strong>plugin</strong> architecture is similar to the design in figure 2.2.<br />
2.2.3 Discussion on existing Plugin Designs<br />
There are existing <strong>plugin</strong>-based application developments <strong>and</strong> framework designs. A lightweight<br />
approach is described in [13]. It discusses the <strong>plugin</strong> concept formally as a design<br />
pattern <strong>and</strong> makes use <strong>of</strong> dynamic loading <strong>of</strong> classes <strong>and</strong> modules. It includes a <strong>plugin</strong><br />
manager to identify <strong>and</strong> load classes that implement interfaces known to the main application.<br />
One application can be extended with multiple <strong>plugin</strong>s, but their work does not cope<br />
with adding <strong>plugin</strong>s to other <strong>plugin</strong>s.<br />
In [16], a PluggableComponent architecture involves a management component (registry)<br />
that h<strong>and</strong>les different types <strong>of</strong> <strong>plugin</strong>s. All PluggableComponents are derived from<br />
the PluggableComponent base class. The registry is configured via a tool <strong>and</strong> therefore,<br />
the administrator or developer decides which components are used. This way, the application’s<br />
configuration is human driven. Hence, the system cannot work without human<br />
interaction.
Chapter 2 Background 8<br />
Plugin application development on another <strong>level</strong> is provided by Rich Client Platforms<br />
(RCP). One famous open source framework is the Eclipse RCP that is an implementation<br />
<strong>of</strong> the pure-<strong>plugin</strong> architecture as described by Birsan in [1]. The hosting application is<br />
reduced to a no-functionality runtime engine for <strong>plugin</strong>s. Any <strong>plugin</strong> is free to define<br />
new extension points. Other <strong>plugin</strong>’s functionality <strong>and</strong> even the kernel can be extended<br />
by new <strong>plugin</strong>s. A manifest file (XML) describing its interconnections in detail has to be<br />
included by every <strong>plugin</strong> [3]. Finally, a program obtains functionality <strong>and</strong> becomes useful<br />
for end-users only through a federation <strong>of</strong> <strong>plugin</strong>s.<br />
The designs mentioned above do all fol<strong>low</strong> the dynamic <strong>plugin</strong> loading principle. However,<br />
this is a nice feature, but not really necessary for the design <strong>of</strong> the framework in this thesis.<br />
The project asks for easy development <strong>and</strong> a compact application topology. Furthermore,<br />
a high number <strong>of</strong> modules as described in [1] might lead to confusing file structures <strong>and</strong><br />
difficult development.
Chapter 3<br />
Design <strong>and</strong> Implementation<br />
In this chapter a <strong>low</strong> <strong>level</strong> framework is designed <strong>and</strong> modelled, that will be able to comply<br />
with most <strong>of</strong> the requirements outlined in the previous chapter. In an initial step a<br />
different design approaches are validated <strong>and</strong> fol<strong>low</strong>ing a conceptual framework model<br />
<strong>and</strong> its general functionality behind the visualisation is presented. Next, the framework<br />
is broken down into the different components <strong>and</strong> finally an analysis describes how these<br />
components will be able to satisfy the desired requirements.<br />
3.1 Design Considerations<br />
The required specifications are described in section 2.1.2, section 2.2 <strong>and</strong> especially 2.2.3<br />
present a set <strong>of</strong> different approaches to develop <strong>plugin</strong> frameworks. While comparing<br />
requirements <strong>and</strong> existing approaches listed in section 2.2.3, only a small number <strong>of</strong> intersections<br />
can be found. In this project, a <strong>plugin</strong> is referred to be a GUI component providing<br />
visualisation features <strong>and</strong> containing predetermined components like buttons <strong>and</strong> menus.<br />
Accordingly, <strong>plugin</strong>s are supposed to have a common appearance, share a mutual design<br />
<strong>and</strong> therefore have to be limited within their fundamental characteristics. Since GUI<br />
components must be implemented by the use <strong>of</strong> the Swing libraries fol<strong>low</strong>ing the requirements<br />
in section 1.1, <strong>plugin</strong> classes must extend at least javax.swing.JComponent or even<br />
javax.swing.JPanel to ensure a consistent GUI appearance <strong>and</strong> development guidelines.<br />
These limitations can be enforced by inheritance. A superclass predefines the common<br />
look <strong>and</strong> feel <strong>and</strong> rudimental features in such a way as to provide these characteristics to<br />
each subclass, respectively each extending <strong>plugin</strong> class. Since [13] deals with an interface<br />
structure that does not cope with the requirements, it won’t be applied to this project. The<br />
concept discussed by Völter in [16] implies, that every <strong>plugin</strong> is derived from Pluggable-<br />
Component (see section 2.2.3). This lacks flexibility, because in Java every class cannot<br />
extend more than one superclass. Hence, <strong>plugin</strong>s that extend PluggableComponent are<br />
unable to extend a necessary Swing (e.g. JPanel) class to be displayed in the application’s<br />
main frame (see section 1.1).
Chapter 3 Design <strong>and</strong> Implementation 10<br />
Furthermore, the data exchange <strong>and</strong> synchronisation <strong>of</strong> interactions between <strong>plugin</strong>s asks<br />
for a tight binding <strong>of</strong> the <strong>plugin</strong>s. This is another point, why <strong>plugin</strong> classes must be strongly<br />
limited within their basic development or at least need to fulfil the requirements given by<br />
a superclass to ensure proper behaviour.<br />
The next sections introduce an implementation <strong>of</strong> a design, able to cope with the requirements<br />
<strong>of</strong> this work.<br />
3.2 Overview <strong>of</strong> the Framework Design<br />
Figure 3.1 shows the general concept <strong>of</strong> the framework <strong>and</strong> how it is embedded in the<br />
s<strong>of</strong>tware program. The principle <strong>of</strong> subclassing is used to realise good extension capabilities.<br />
Upcoming threads when using inheritance are discussed in 3.3.1. An abstract root<br />
class with rudimental features provides basic operations <strong>and</strong> ensures the communication<br />
constraints mentioned in section 2.1.2. Plugin classes extend the root class one <strong>of</strong> its subclasses,<br />
providing more features than the root class. This approach is discussed in section<br />
3.3. Moreover, the root class contains a data object <strong>and</strong> likewise each inherited <strong>plugin</strong>.<br />
This PluginData class holds the JavaBeans specifications <strong>and</strong> fires change events every<br />
time a property, e.g. data set, changes. Section 3.5 describes the data exchange.<br />
The PluginH<strong>and</strong>ler class is responsible for many different tasks. Primarily, it registers <strong>and</strong><br />
adds <strong>plugin</strong>s to the main frame <strong>and</strong> takes care <strong>of</strong> the right display position in the main<br />
panel. Details will be explained in section 3.4.<br />
exte nds<br />
Plu gin N o 1<br />
Pan el<br />
listen<br />
<strong>and</strong> change<br />
Plugin No 2<br />
Panel<br />
A bstractPlu gin<br />
set / get selected data<br />
P lu ginD ata (JavaBean)<br />
- contains arbitrary data types as<br />
properes<br />
- fires change events<br />
M ain Fram e<br />
M ain Pan el<br />
select <strong>and</strong> get data from database via API<br />
Tree Dialo g<br />
register / add Plugin<br />
PluginH <strong>and</strong> ler<br />
registerPlugin(JApplet applet, String <strong>plugin</strong>ClassName)<br />
{// register <strong>plugin</strong> without instantiation}<br />
addPlugin(String <strong>plugin</strong>ClassName)<br />
{// create instance <strong>and</strong> add to main panel }<br />
Figure 3.1: Overview <strong>of</strong> framework design
Chapter 3 Design <strong>and</strong> Implementation 11<br />
3.3 Introducing the Plugin Architecture<br />
3.3.1 Interface vs. Abstract Classes in Project Context<br />
Inheritance is a powerful mechanism regarding s<strong>of</strong>tware development, but is appropriate<br />
only when a genuine subtype relationship exists between the subclass <strong>and</strong> the superclass<br />
[2]. Subclassing involves some problems, the developer must be aware <strong>of</strong>. Classes, especially<br />
designed <strong>and</strong> documented for extension, reduce the threat <strong>of</strong> erroneous behaviour<br />
when they are extended by subclasses. In the first place, self-used overridable methods<br />
must be accurately documented to avoid unconscious overriding <strong>and</strong> therefore unpredictable<br />
behaviour in subclasses. Another danger is the updating <strong>of</strong> superclasses. Assuming<br />
that a subclass overrides a method with certain functionality to prohibit decisive operations<br />
within this method. Then, if its superclass acquires new methods with similar functionality<br />
in subsequential releases, these methods can easily by-pass the prohibitions made in<br />
the subclass unless they are not analogically overridden. Most objections to inheritance<br />
stem from overriding, but through merely adding new methods to superclasses, avoidance<br />
<strong>of</strong> overriding methods in subclasses <strong>and</strong> precise documentation, many problematic issues<br />
can be minimised.<br />
On the one h<strong>and</strong> many designs prefer interfaces over abstract classes or inheritance in<br />
general. They al<strong>low</strong> a construction <strong>of</strong> nonhierarchical frameworks [2] <strong>and</strong> provide high<br />
flexibility. Additionally, the previously mentioned difficulties with overridable methods<br />
do not appear. On the other h<strong>and</strong> there are two drawbacks on interfaces that play an important<br />
role in this work.<br />
Evolving abstract classes is much easier than evolving interfaces [2]. Supposed a new<br />
version <strong>of</strong> an abstract class contains new concrete methods. This modification is automatically<br />
passed to all subclasses, so that they do all provide these new methods. In particular,<br />
the GUI design progress benefits from the ease <strong>of</strong> abstract class development, because<br />
GUI alteration or new features (e.g. buttons or menus) can be made in the superclass <strong>and</strong><br />
thenceforward, are present in each subclass. For interfaces, this does not work.<br />
By the time an interface is released <strong>and</strong> implemented to a certain extent, it is almost impossible<br />
to change. Changes must be considered in every class that implements the interface.<br />
This is hardly manageable if you deal with many classes <strong>and</strong> due to the fact, that the interface<br />
developer does not know which classes use the interface. For abstract classes this<br />
issue exists to a certain degree. Changing existing methods, variables or return types raises<br />
similar problems. But, adding new features, methods, variables does not affect existent implementations<br />
in subclasses. In contrast, subclasses get updated <strong>and</strong> equipped with those<br />
additional features without any further changing. To summarise, interfaces are generally<br />
the best way to define types that al<strong>low</strong> heterogeneous implementations. Though, when<br />
ease <strong>of</strong> use is deemed more important than flexibility <strong>and</strong> power, abstract classes are the<br />
right way to define a type with the awareness <strong>of</strong> implicated limitations [2].
Chapter 3 Design <strong>and</strong> Implementation 12<br />
3.3.2 Presentation <strong>of</strong> the Plugin Hierarchy <strong>and</strong> Configuration<br />
According to the discussion in section 3.3.1, the principle <strong>of</strong> subclassing is considered as<br />
good practise for this project. Classes inherit (extend in Java) from their superclasses thus<br />
once implemented methods <strong>and</strong> fields in a superclass can be used in every subclass. Redundant<br />
code <strong>and</strong> additional, unnecessary programming can be avoided. A contributing<br />
aspect is the keyword abstract. Classes that are declared abstract in Java can contain fields<br />
that are not static <strong>and</strong> final <strong>and</strong> they can contain implemented methods. Abstract classes<br />
cannot be instantiated. They just serve as a base class that provides certain fields <strong>and</strong> methods.<br />
They have a certain similarity to interfaces in Java, except a partial implementation<br />
is provided, leaving it to subclasses to complete <strong>and</strong> extend it. Interfaces in Java do not<br />
provide the features mentioned above <strong>and</strong> on that account subclassing is favoured over<br />
interfaces here.<br />
Abstract classes facilitate the <strong>plugin</strong> development. Figure 3.2 illustrates the chosen concept<br />
<strong>and</strong> its application to this project. There is a base class called AbstractPlugin. The precondition<br />
for every new abstract or concrete class with further functionality is to extend this<br />
class. Assuming that this precondition maintains, every inherited class is equipped with<br />
essential components. The fol<strong>low</strong>ing itemisation specifies some <strong>of</strong> them.<br />
• A manager object to access the database,<br />
• a toolbar including buttons to access the most important features,<br />
• the PluginData object to store received data <strong>and</strong><br />
• predetermined panels preserve graphical layout.<br />
Figure 3.2 depicts the present build <strong>of</strong> existing abstract classes <strong>and</strong> shows two concrete<br />
classes MyArbitraryPlugin <strong>and</strong> DigitalChart, that can be seen as examples for discrete,<br />
usable <strong>plugin</strong>s developed for this application.<br />
Moreover, <strong>plugin</strong>s that do not comply with the predetermined subclassing requirements<br />
cannot be added to the application. This behaviour is ensured through the restrictions<br />
in the PluginH<strong>and</strong>ler implementation. The PluginH<strong>and</strong>ler (see section 3.4) exclusively<br />
accepts subclasses <strong>of</strong> AbstractPlugin. Any other classes won’t be h<strong>and</strong>led, registered or<br />
added to the main panel <strong>and</strong> are consequently useless.
Chapter 3 Design <strong>and</strong> Implementation 13<br />
AbstractPlugin<br />
AbstractChartPlugin<br />
MyArbitraryPlugin<br />
AbstractCartesianChartPlugin<br />
AbstractFullCartesianChartPlugin<br />
DigitalChart<br />
Figure 3.2: Diagram <strong>of</strong> <strong>plugin</strong> inheritance<br />
3.3.3 Extending the Framework with new Plugins<br />
The ability to extend the application with new <strong>plugin</strong>s or new abstract classes that provide<br />
additional features to further <strong>plugin</strong>s is limited, but possible <strong>and</strong> desirable to a certain<br />
degree. The project’s requirements ask for extension capability regarding new <strong>plugin</strong> development.<br />
Extending <strong>plugin</strong>s with other <strong>plugin</strong>s is not required <strong>and</strong> therefore not considered<br />
to provide a lightweight design that is easy to h<strong>and</strong>le. The approach to extension relies on<br />
the concept <strong>of</strong> subclassing explained in section 3.3.1 <strong>and</strong> 3.3.2. New <strong>plugin</strong>s extend one<br />
<strong>of</strong> the given abstract superclasses or, if no superclass fits its needs, it will extend the base<br />
class AbstractPlugin <strong>and</strong> define all <strong>of</strong> its desired features itself. Assumed that these features<br />
are useful for subsequent <strong>plugin</strong>s, a new abstract <strong>plugin</strong> class that extends one <strong>of</strong> the<br />
existing abstract classes might be created. The desired <strong>plugin</strong> extends this abstract <strong>plugin</strong><br />
class <strong>and</strong> adds its appropriate implementation.<br />
This way, <strong>plugin</strong> development, respectively <strong>plugin</strong> extension, is based on a simple convention.<br />
Similarly structured <strong>plugin</strong>s with a st<strong>and</strong>ardised appearance result from the consistent<br />
<strong>and</strong> limited principle <strong>of</strong> inheritance.<br />
The hard-coded <strong>plugin</strong> structure combined with subclassing chosen for the design <strong>and</strong><br />
extension concept <strong>of</strong> this project implies that modifications in any <strong>plugin</strong>’s source code<br />
involves changes in the application’s source code. Consequently, adjusting existent or<br />
adding new <strong>plugin</strong>s entails a recompilation <strong>of</strong> the whole program. Hence, extensive third<br />
party programming is not supported. <strong>Development</strong>, implementation <strong>and</strong> extension are<br />
subject to the application’s programmer.
Chapter 3 Design <strong>and</strong> Implementation 14<br />
3.4 Register <strong>and</strong> add Plugins to the Application<br />
Dynamic <strong>plugin</strong> loading as defined in section 2.2.2 is not requested in this project. For<br />
this reason, scanning external sources, e.g. file archives <strong>and</strong> directories, for <strong>plugin</strong>s is not<br />
necessary. Nevertheless, the project still dem<strong>and</strong>s flexibility, e.g. load an arbitrary number<br />
<strong>of</strong> <strong>plugin</strong>s <strong>of</strong> the same type, <strong>and</strong> as little overhead <strong>of</strong> not used <strong>plugin</strong> instances as possible.<br />
As seen in figure 3.1 there is a class called PluginH<strong>and</strong>ler that meets these conditions.<br />
But every available <strong>plugin</strong> has to be introduced to the <strong>plugin</strong> h<strong>and</strong>ler. Otherwise it cannot<br />
be loaded or added to the main frame. Therefore, the PluginH<strong>and</strong>ler implements two<br />
important methods:<br />
1 public void registerPlugin(JApplet applet, String <strong>plugin</strong>ClassName)<br />
2 {...}<br />
<strong>and</strong><br />
1 public void addPlugin(String <strong>plugin</strong>ClassName)<br />
2 {...}<br />
During the main frame initialisation registerPlugin() is invoked to publish every available<br />
<strong>plugin</strong> via its unique <strong>plugin</strong>ClassName. Within this method, the according resource bundle<br />
location is set <strong>and</strong> a new menu item is added to the <strong>plugin</strong> menu in the main frame’s menu<br />
bar. Until this point, neither a <strong>plugin</strong> has been loaded nor any <strong>plugin</strong> related objects have<br />
been instantiated. What happened is just a publication <strong>of</strong> the available <strong>plugin</strong>s that enables<br />
the user to chose one or more <strong>of</strong> them to start.<br />
Any further steps are taken by the addPlugin() method. As far as a <strong>plugin</strong> menu item is selected<br />
<strong>and</strong> clicked by the user this method is called. Only now the object instantiation takes<br />
place. The concept <strong>of</strong> dynamic class loading is realised through two Java core methods.<br />
These methods are<br />
1 public static Class forName(String <strong>plugin</strong>ClassName)<br />
2 {...}<br />
<strong>and</strong><br />
1 public Constructor getConstructor(Class[] parameterTypes)<br />
2 {...}<br />
Both methods are used in addPlugin(). In Listing 3.1, line 6, a Class object associated<br />
with the class with the given fully qualified <strong>plugin</strong>ClassName is returned. In line 8, a<br />
public constructor <strong>of</strong> that class with the specified parameterTypes is searched <strong>and</strong> invoked<br />
to create a new instance <strong>of</strong> an AbstractPlugin object containing a unique <strong>plugin</strong> ID. After<br />
both method invocations, a newly-created <strong>plugin</strong> object is available to be added to the main<br />
frame (line 12) <strong>and</strong> ready to use. Whenever a <strong>plugin</strong> specific method is called, a downcast
Chapter 3 Design <strong>and</strong> Implementation 15<br />
from AbstractPlugin to the desired <strong>plugin</strong> class is necessary. For this purpose, the Java<br />
programming language provides run-time type identification (RTTI). It is able to find the<br />
exact type <strong>of</strong> an object when a h<strong>and</strong>le to only the base type is available [4].<br />
1 public Integer addPlugin(String <strong>plugin</strong>ClassName)<br />
2 {<br />
3 AbstractPlugin newPlugin = null;<br />
4 <strong>plugin</strong>ID++;<br />
5 // [...]<br />
6 Class
Chapter 3 Design <strong>and</strong> Implementation 16<br />
this downside does not affect the frameworks security concerning unintentional loading <strong>of</strong><br />
malicious classes, because the application quits immediately when a ClassNotFoundException<br />
is caught.<br />
3.5 Data Reception through a dedicated API<br />
There are many ways for the transfer <strong>of</strong> data between client <strong>and</strong> server. Here, there is<br />
a predetermined way to do this. Data connection, e.g. request new data rows from a<br />
dedicated database <strong>and</strong> add new values to the database, has been made easy. The existence<br />
<strong>and</strong> desired use <strong>of</strong> a client API called JEVis Client API (JECAPI) simplifies this issue.<br />
It provides a configurable h<strong>and</strong>ler object, that establishes a connection with the desired<br />
database. The AbstractPlugin class creates a given, default tree table manager object. This<br />
is passed to a new dialog object that presents the connected database structure in a tree<br />
view. Hence, data rows can be browsed, selected <strong>and</strong> loaded into the <strong>plugin</strong>’s data storage<br />
object PluginData. The PluginData class <strong>and</strong> its tasks are described in section 3.6.<br />
Different ways to receive data from external sources are possible, but not natively implemented.<br />
Further development or special needs might result in additional ways <strong>of</strong> communication.<br />
Although, utilising the JECAPI is desired <strong>and</strong> this application is especially<br />
prepared for its use, there is no directive to use it. The framework is open for any communication<br />
channel, but provides no built-in support for web services other than the included<br />
JECAPI. If ongoing development requires more communication channels, the framework<br />
has to be extended in a way that supports these new requirements <strong>and</strong> still comply with the<br />
specifications outlined in this work.<br />
3.6 Data Management <strong>and</strong> Interchange within the<br />
Framework<br />
The data management is centralised in an object called PluginData. Its design is related<br />
to the JavaBeans concept (see section 3.6.1 <strong>and</strong> serves as the main data storage <strong>and</strong><br />
exchange component for every single <strong>plugin</strong>. It guarantees consistency through the use<br />
<strong>of</strong> the observer design pattern introduced in [6]. Section 3.6.2 covers this issue in more<br />
detail.
Chapter 3 Design <strong>and</strong> Implementation 17<br />
3.6.1 Configuration <strong>of</strong> the PluginData Class<br />
In fact, the JavaBeans architecture is a component model which enables developers to<br />
create reusable s<strong>of</strong>tware component that can be visually manipulated in builder tools. But<br />
this project only calls upon the core features <strong>of</strong> the JavaBeans concept. The fol<strong>low</strong>ing list<br />
briefly describes key bean conventions.<br />
• The default constructor must be public for easy instantiation.<br />
• All properties must comply with the principle <strong>of</strong> information hiding via private access<br />
modifiers.<br />
• The class properties must be accessible using get, set or other accessor/mutator methods<br />
that fol<strong>low</strong> a st<strong>and</strong>ardised naming convention<br />
• The class should implement the Serializable interface.<br />
The PluginData class fol<strong>low</strong>s the conventions listed above. If a class is defined according<br />
to given specifications, it is easier to underst<strong>and</strong> <strong>and</strong> maintained. Subsequent extensions or<br />
modifications are limited within these guidelines. If further development holds on to these<br />
guidelines, the PluginData class is extensible with arbitrary properties <strong>and</strong> data types <strong>and</strong><br />
thereby usable in every upcoming <strong>plugin</strong>. There is one property for every desired data<br />
type that should be stored in the PluginData object. New properties can be added at any<br />
time during development. Data that is received from an external source gets stored in<br />
the associated property. Once stored, it can be used <strong>and</strong> shared among other <strong>plugin</strong>s. If<br />
one <strong>plugin</strong> wants to set or get another <strong>plugin</strong>’s property value it calls the getPluginData()<br />
method via the global PluginH<strong>and</strong>ler object. This way, <strong>plugin</strong>s can interchange their data<br />
<strong>and</strong> their property values respectively.<br />
3.6.2 Notification <strong>and</strong> Reaction to Changes in the PluginData Object<br />
The Observer pattern "defines a one-to-many dependency between objects so that when<br />
one object changes state, all its dependents are notified <strong>and</strong> updated automatically."[6].<br />
There are two key objects called subject <strong>and</strong> observer. Any number <strong>of</strong> observers can be<br />
added to the subject <strong>and</strong> if the subject’s state changes, all observers will be notified. Hence,<br />
consistency is ensured between the state <strong>of</strong> the subject <strong>and</strong> behaviour <strong>of</strong> the observer objects.<br />
The Java programming language provides a comfortable implementation <strong>of</strong> the Observer<br />
pattern called PropertyChangeListener that is especially developed for changes <strong>of</strong> properties<br />
in JavaBeans components. This design meets the dem<strong>and</strong>s <strong>of</strong> consistency between
Chapter 3 Design <strong>and</strong> Implementation 18<br />
data <strong>and</strong> view according to the model view controller concept.<br />
The class that should be notified <strong>of</strong> changes in particular properties needs to implement<br />
the PropertyChangeListener interface. Furthermore, it implements the according property-<br />
Change(PropertyChangeEvent evt) method <strong>and</strong> defines custom code that is executed every<br />
time a PropertyChangeEvent is received by that class. Those events are fired by the subject<br />
(see 3.6.2), in this case the PluginData object. The PluginData class contains an instance<br />
<strong>of</strong> PropertyChangeSupport <strong>and</strong> delegates various work to it, especially firing appropriate<br />
PropertyChangeEvents.<br />
M yConcre tePlugin<br />
public void propertyChange(P ropertyChangeEvent evt)<br />
{ // insert code to execute on property change }<br />
invoke propertyChange()<br />
fire change event<br />
PluginD ata<br />
p ub lic Strin g PRO P_ N U M B ERS = “num be rs“;<br />
p riv ate Vecto r n um be rs;<br />
p riv ate Pro p ertyC h ang eSu p po rt pcs;<br />
Figure 3.3: Outline <strong>of</strong> property change event h<strong>and</strong>ling<br />
Here, the PluginData class contains properties <strong>and</strong> an instance <strong>of</strong> PropertyChangeSupport<br />
that fires PropertyChangeEvents as soon as a property gets changed. Every <strong>plugin</strong> inherits<br />
the PropertyChangeListener interface by extending an abstract <strong>plugin</strong> class (see 3.3), but<br />
implements its own propertyChange() method. Thereby, the <strong>plugin</strong>’s behaviour towards<br />
incoming change events is completely customisable. Figure 3.3 sketches the general structure.<br />
3.7 Tools <strong>and</strong> Libraries<br />
The basic tools used are the IBM ILOG JViews Charts (see section 2.1.3) <strong>and</strong> Swing libraries.<br />
Additionally, the present web service JECPAI is used for electronic data interchange.<br />
Assuming that the IBM ILOG JViews Charts libraries adhere to the model-view-controller<br />
architecture, they suit this project’s design very well. The Swing architecture is rooted<br />
in the MVC design, too, although it can be seen as a modified MVC [5]. Both libraries
Chapter 3 Design <strong>and</strong> Implementation 19<br />
fol<strong>low</strong> the same guidelines <strong>and</strong> cooperate in a very valuable manner. The data storage <strong>and</strong><br />
exchange (see section 3.5) in this project cover elements <strong>of</strong> the MVC idea as well. Hence,<br />
these three parts work in collaboration.<br />
The JECAPI <strong>and</strong> its trailed web service contribute to the data type specifications. It implements<br />
a data request method that returns a predetermined data object containing all<br />
necessary information <strong>and</strong> values. Due to the fact that the returned object holds certain<br />
constraints the framework does not need to care for possible faulty data or prohibited data<br />
types. If the database contains entries that cannot be processed within the framework,<br />
this data is not even exported by the JECAPI, because the JECAPI h<strong>and</strong>les such incidents<br />
independently.<br />
3.8 Suggestions how to increase Testability<br />
This project’s original appointment is the initialisation <strong>of</strong> an easy to use <strong>and</strong> clearly structured<br />
<strong>low</strong>-<strong>level</strong> framework to support <strong>plugin</strong> extension for dedicated application. Primarily,<br />
it is designed to maintain a comfortable <strong>and</strong> consistent graphical user interfaces for applications<br />
<strong>and</strong> its <strong>plugin</strong>s. Design issues regarding testability <strong>and</strong> testing in general therefore<br />
were not explicitly focused during development. Nevertheless, these questions are not<br />
ignored <strong>and</strong> will be covered theoretically in this section. Hence, future development might<br />
take advantage <strong>of</strong> these proposals <strong>and</strong> tend to result in source code refactoring.<br />
In [10], Jungmayr outlines different approaches to contribute to <strong>low</strong> test costs <strong>and</strong> increased<br />
quality <strong>of</strong> the product under test:<br />
• improve the s<strong>of</strong>tware specification <strong>and</strong> documentation,<br />
• reduce or change functional requirements to ease testing,<br />
• use better test techniques,<br />
• use better test tools,<br />
• improve the test process,<br />
• train people, <strong>and</strong><br />
• improve the s<strong>of</strong>tware design <strong>and</strong> implementation.<br />
S<strong>of</strong>tware specifications <strong>and</strong> the application’s requirements won’t change in the near future.<br />
Well documented source code administers to a better underst<strong>and</strong>ing <strong>and</strong> a more efficient<br />
test case creation. If the application lacks this feature, comprehensive documentation can<br />
be amended with little effort. Test tools, techniques <strong>and</strong> processes to some extent rely on<br />
the developer’s preferences <strong>and</strong> choice.<br />
Improvements in design <strong>and</strong> implementation are considered to create the most enduring<br />
benefits in terms <strong>of</strong> testability. Object-oriented (OO) s<strong>of</strong>tware design in contrast to sequential<br />
implementations is regarded to be correlated with <strong>low</strong> testability due to the prin-
Chapter 3 Design <strong>and</strong> Implementation 20<br />
ciples <strong>of</strong> inheritance <strong>and</strong> information hiding [15]. However, there are design approaches<br />
to counteract this drawback <strong>of</strong> OO programming or at least to weaken its influence on<br />
testability.<br />
J.E. Payne et al. [15] discuss s<strong>of</strong>tware contracts <strong>and</strong> their impact on testability. The<br />
fol<strong>low</strong>ing three essential elements describe a formal or systematic class specification <strong>and</strong><br />
its associated methods:<br />
• Invariant: A condition that applies to any instance <strong>of</strong> a class at any time or a condition<br />
that should always be true for a specified segment <strong>of</strong> a program.<br />
• Precondition: A condition that must be true prior to calling a method.<br />
• Postcondition: A condition that the method itself promises to achieve.<br />
These three roles collectively support what is called the design-by-contract model <strong>of</strong> programming.<br />
They characterise the behaviour <strong>of</strong> a class <strong>and</strong> the requirements <strong>of</strong> its proper<br />
use. In [15], the attention is turned to assertions to implement preconditions, postconditions<br />
<strong>and</strong> class invariants. The Java programming language has built-in support for this<br />
model since J2SE 1.4 1 . In fact, it supports assertions <strong>and</strong> introduces the keyword assert<br />
to provide a source code implementation <strong>of</strong> the elements listed above. Listing 3.3 is based<br />
on code snippets <strong>of</strong> an integer stack taken from [12] <strong>and</strong> shows how assertions are used in<br />
Java. Pop <strong>and</strong> push methods are equipped with assert statements to verify correct values<br />
<strong>and</strong> operation results. The assert comm<strong>and</strong> checks wether a boolean expression is true or<br />
false. If true, nothing happens, but if the expression evaluates to false, the system throws<br />
an AssertionError containing the given string after the colon. The system’s stack trace is<br />
printed including the AssertionError message <strong>and</strong> the program aborts.<br />
1 public int pop() {<br />
2 // precondition<br />
3 assert !isEmpty() : "Stack is empty";<br />
4 return stack[--num];<br />
5 }<br />
6 public void push(int element) {<br />
7 // precondition<br />
8 assert num < capacity : "stack is full";<br />
9 int oldNum = num;<br />
10 stack[num] = element;<br />
11 // postcondition<br />
12 assert num == oldNum + 1 && stack[num-1] == element : "<br />
problem with counter";<br />
13 // class invariant<br />
14 assert inv();<br />
15 return;<br />
16 }<br />
1 Java 2 Platform, St<strong>and</strong>ard Edition v 1.4
Chapter 3 Design <strong>and</strong> Implementation 21<br />
17 private boolean inv() {<br />
18 return (num >= 0 && num < capacity);<br />
19 }<br />
Listing 3.3: Class showing use <strong>of</strong> precondition, postcondition <strong>and</strong> class invariant<br />
Assertions in Java are further used in classes designed for multithreading. A common<br />
manner is to implement a precondition through an assert statement in nonpublic methods<br />
to check whether or not some lock is held. This issue will not be covered in this work,<br />
because the framework <strong>and</strong> the sample application are both not made for multithreading,<br />
respectively do not contain multithreaded classes.<br />
S<strong>of</strong>tware design-for-testability <strong>and</strong> consequently the use <strong>of</strong> s<strong>of</strong>tware contracts is advocated<br />
in [15]. Implementing assertions is regarded as good practise to achieve a high <strong>level</strong><br />
<strong>of</strong> object observability <strong>and</strong> to correct internal states within a program. Therefore, they<br />
can significantly affect the overall testability <strong>of</strong> object-oriented s<strong>of</strong>tware. Numerous design<br />
approaches exist to increase testability. A useful overview <strong>of</strong> interesting concepts is<br />
presented by Jungmayr in [10].
Chapter 4<br />
Conclusion <strong>and</strong> Outlook<br />
To underst<strong>and</strong> the chosen approaches in the previous chapters it is important to know<br />
in what domain the application is working <strong>and</strong> developed. The team <strong>of</strong> programmers<br />
is separated into different fields <strong>and</strong> only a very small part is responsible for the GUI<br />
<strong>and</strong> visualisation tasks. Anyway, all <strong>of</strong> them cooperate <strong>and</strong> should benefit from the new<br />
s<strong>of</strong>tware <strong>and</strong> <strong>plugin</strong> design.<br />
Because subclassing is chosen for the design <strong>and</strong> extension concept <strong>of</strong> this project, it lacks<br />
dynamic extensibility to a certain extent. The source code has to be recompiled every<br />
time changes want to be made to <strong>plugin</strong>s or other <strong>plugin</strong>s are ready to be added to the<br />
application. In fact, this is a disadvantage in terms <strong>of</strong> flexibility <strong>and</strong> changeability. But,<br />
granted that the s<strong>of</strong>tware that is supposed to use these concepts is more likely to be used<br />
within one company, maintained <strong>and</strong> edited by a small group <strong>of</strong> programmers, than to be<br />
spread out to arbitrary developers, an easy <strong>and</strong> straightforward way <strong>of</strong> development <strong>and</strong><br />
underst<strong>and</strong>ing is more important than a very complex <strong>and</strong> flexible structure. The s<strong>of</strong>tware<br />
<strong>and</strong> especially its <strong>plugin</strong>s will be a selling product <strong>of</strong> the Envidatec GmbH. Most likely,<br />
the s<strong>of</strong>tware will run on a server, accessible trough a web portal. The s<strong>of</strong>tware runs in a<br />
central place, easy to manage <strong>and</strong> maintained. Updates <strong>and</strong> changes need to be applied to<br />
one program in one place only. Consequently, the effort to publish new versions is kept<br />
within reasonable limits.<br />
In the future, many more <strong>plugin</strong>s will be developed <strong>and</strong> implemented. All <strong>of</strong> them will use<br />
the framework provided by this project. The framework itself is extensible as well. Further<br />
projects might extend it with more flexibility or more abstract classes to provide new drafts<br />
for a new range <strong>of</strong> concrete <strong>plugin</strong>s. This way, unforeseen task might be performed with<br />
the help <strong>of</strong> this framework.<br />
Furthermore, applying design concepts to increase testability might be an interesting task<br />
for subsequent development. Some ideas are outlined in this work, but there will be many<br />
more ways to make the s<strong>of</strong>tware more robust <strong>and</strong> to improve its testability.
Bibliography<br />
[1] D. Birsan. On Plug-Ins <strong>and</strong> Extensible Architectures. Queue, 3(2):40–46, 2005.<br />
[2] J. Bloch. Effective Java (2nd Edition) (The Java Series). Prentice Hall, 2008.<br />
[3] R. Chatley, S. Eisenbach, <strong>and</strong> J. Magee. Painless <strong>plugin</strong>s. Technical report, Department<br />
<strong>of</strong> Computing, Imperial College London, 2003.<br />
[4] B. Eckel. Thinking in Java. Prentice Hall, 2003.<br />
[5] A. Fowler. A Swing Architecture Overview - The Inside Story on<br />
JFC Component Design. http://java.sun.com/products/jfc/tsc/<br />
articles/architecture/. [Online; accessed 25-February-2010].<br />
[6] E. Gamma, R. Helm, R. Johnson, <strong>and</strong> J. Vlissides. Design Patterns. Elements <strong>of</strong><br />
Reusable Object-Oriented S<strong>of</strong>tware. Addison-Wesley, 1995.<br />
[7] D. Govoni. Java Application Frameworks. John Wiley & Sons, 1999.<br />
[8] I. S. Group. IBM ILOG JViews Charts - Features <strong>and</strong> Benefits. http:<br />
//www-01.ibm.com/s<strong>of</strong>tware/integration/visualization/<br />
jviews/charts/about/?S_CMP=wspace. [Online; accessed 4-February-<br />
2010].<br />
[9] I. S. Group. IBM ILOG JViews Charts v8.6 - Introducing JViews Charts.<br />
ftp://public.dhe.ibm.com/s<strong>of</strong>tware/websphere/ilog/docs/<br />
visualization/jviews86/jviews-charts86/ps_usrintcharts.<br />
pdf. [Online; accessed 8-February-2010].<br />
[10] S. Jungmayr. Design for testability. In Proceedings <strong>of</strong> CONQUEST 2002, pages<br />
57–64, Nuremberg, Germany, September 18-20 2002.<br />
[11] P. Kuchana. S<strong>of</strong>tware architecture design patterns in Java. Auerbach Publications,<br />
Boston, MA, USA, 2004.<br />
[12] Q. H. Mahmoudp. Using assertions in java technology. http://java.sun.
Bibliography 24<br />
[On-<br />
com/developer/technicalArticles/JavaLP/assertions/.<br />
line; accessed 9-April-2010].<br />
[13] J. Mayer, I. Melzer, <strong>and</strong> F. Schweiggert. Lightweight plug-in-based application development.<br />
NODe ’02: Revised Papers from the International Conference NetObjectDays<br />
on Objects, Components, Architectures, Services, <strong>and</strong> Applications for a<br />
Networked World, pages 87–102, 2003.<br />
[14] M. Naftalin <strong>and</strong> P. Wadler. Java generics <strong>and</strong> collections. O’Reilly Media, Inc.,<br />
2006.<br />
[15] J. E. Payne, R. T. Alex<strong>and</strong>er, <strong>and</strong> C. D. Hutchinson. Design-for-Testability for<br />
Object-Oriented S<strong>of</strong>tware. Object Magazine, 7(5):34–43, 1997.<br />
[16] M. Völter. Pluggablecomponent - a pattern for interactive system configuration. In<br />
Proceedings <strong>of</strong> the Fourth European Conference on Pattern Languages <strong>of</strong> Programming<br />
<strong>and</strong> Computing, EuroPLoP 99, Irsee, Germany, July 7-10 1999.<br />
[17] Wikipedia. Model view controller - Wikipedia the free Encyclopedia. http://de.<br />
wikipedia.org/w/index.php?title=Plagiat&oldid=43117308.<br />
[Online; accessed 4-February-2010].
List <strong>of</strong> Figures<br />
2.1 Example <strong>of</strong> a stock chart designed with IBM ILOG JViews Charts . . . . 5<br />
2.2 General <strong>plugin</strong> structure . . . . . . . . . . . . . . . . . . . . . . . . . . 6<br />
2.3 Hard-coded <strong>plugin</strong> structure in this project . . . . . . . . . . . . . . . . 6<br />
3.1 Overview <strong>of</strong> framework design . . . . . . . . . . . . . . . . . . . . . . . 10<br />
3.2 Diagram <strong>of</strong> <strong>plugin</strong> inheritance . . . . . . . . . . . . . . . . . . . . . . . 13<br />
3.3 Outline <strong>of</strong> property change event h<strong>and</strong>ling . . . . . . . . . . . . . . . . . 18