You are on page 1of 86

Czech Technical University in Prague Faculty of Electrical Engineering

ˇ VUT FEL katedra poc C ˇı ´tac ˇu ˚

Diploma Thesis

Eclipse RCP application development Mari´ an Kukuˇ cka

Supervisor: Ing. Andrej Zachar

Study program: Computer Science and Engineering master May 2007

ii

Podˇ ekov´ an´ ı
M´ e podˇ ekov´ an´ ı patˇ r´ ı Ing. Andrejovi Zacharovi za jeho obˇ etavou pomoc pˇ ri tvorbˇ e diplomov´ e pr´ ace.

iii

iv

Nem´ am z´ avaˇ zn´ y d˚ uvod proti uˇ zit´ ı tohoto ˇ skoln´ ıho d´ ıla ve smyslu §60 Z´ akona ˇ c.. ....Prohl´ aˇ sen´ ı Prohlaˇ suji...2007 v ................ 121/2000 Sb............... ˇ ze jsem svou diplomovou pr´ aci vypracoval samostatnˇ e a pouˇ zil jsem pouze podklady uveden´ e v pˇ riloˇ zen´ em seznamu....... o pr´ avech souvisej´ ıc´ ıch s pr´ avem autorsk´ ym a o zmˇ enˇ e nˇ ekter´ ych z´ akon˚ u (autorsk´ y z´ akon)...5........ o pr´ avu autorsk´ em.. V Praze dne 20...........

vi .

vii .Abstract This work describes and demonstrates the use of the Eclipse RCP framework by the development of multiplatform desktop applications using principles of Extreme Programming. Abstrakt Pr´ ace popisuje a demonstruje pouˇ zit´ ı Eclipse RCP frameworku pˇ ri v´ yvoji multi-platformov´ ych desktopov´ ych aplikac´ ı vyuˇ zit´ ım princip˚ u Extr´ emn´ ıho Programov´ an´ ı.

viii .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2. .2. . . . .2. . . . . . . ix . . . . 5. . . . . . . . . . . . .Contents List of Figures List of Tables 1 Introduction 2 Eclipse platform 2. . . . . . . . . . . . . . . . . . 2. 4. . . . . . . . . .1 Configuration . .10 On-site Customer . . . . . . . . . . . . . . . . . . . . . . .1. . . . . . . . . . . . . . . . 4. . . . . . . . . . . . .1. . . . . . . .4 The Generic Workbench . . . . .2 View . . . . . . . . . . . . . . 5. . . . . . . . . . . . . . . . . . . . . . . . . .2. relational paradigm 5. .2. . . . . .2 Mapping . . . . . . . . . . . 4. .2. . . . . . . . . . . . . 3. . . . . . . . . . . . . . . . .1 Standard Widget Toolkit . . . . . . . . . . . . . . . 5 Object Relational Mapping 5. . . . . . . . . . . . . . .2. . . . . . . . . . . . . . 4. . . . . . . . 2. . . .2 Acceptance tests .1 Unit tests . . . . . . . . . .11 40-hour week . . . . .1 OSGi framework . . . . . . . . .2. . . .1.1. 2. . 4. . . . . . . . . . . . . . . .2 Iteration planning . . . . . . . . . . . . . . . . . .2. . . . . . . . . 4. . . . . . . .4. . . . 4. . .4 Simple Design . . . .2 Pillars of Extreme Programming . . . .2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2. . . . . .7 Pair programming . . . . . . . . . . . . . . . . . . . . . . .1 The Planning Game . . . . .2 Eclipse platform tools . . . . . . . . . . . . . . . . .2 Small releases . 4. . . . 3 Eclipse user interface framework 3. . . . . . 4. . . . . .2 Applications and Products 2. . . . . . . . . . . . . . . .1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2. . . .1 Release planning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2. 2. . . . . . . . . . .2. 2. . . . . . . . . .5. . . . . . . . . . . . . . . . . . . .1. . . .9 Coding standards .5 Continuous testing and integration 4. . . . . . . . . . . . . 4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3 Objects manipulation . . . . . . .8 Collective code ownership . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2. . . . . . 4 Extreme Programming 4. . . . . 4. . . .3 System Metaphor . .4. . . . . . . . . . . . . . . .2. . . . .1.4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1. .1 Perspective . . . . . . .1. . . . . . . . . 4. .6 Refactoring .2. . . . . . . . . . . . . . . . . . 2. . . . . . .1. . . . . . . . . 2. . . . . . . . . . .2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4. . . . . . . . . . . . . . . . . .1. . . . . . . . . . . . 4. . . .2. . . . . . . .1 Object vs.3 SWT/JFACE . . . . .2. . . . . . . . . .1 Getting Agile . . . . . . . . 5. . .3 Editor . . . . . . .2 Hibernate . . . . . . . . . . . . .2 The Platform Runtime . . . . . . . . . xi xii 1 2 3 3 5 5 6 7 7 8 8 8 9 11 12 13 19 19 19 19 19 21 21 21 21 22 22 22 23 23 24 24 24 24 26 26 27 27 28 30 . . . . . . . . .5. . . . . . . . . . . . . . . . 2. . . . . . . . . . . . . . . . . . . . . .2 JFace . . . . . . . . . . . 4. .2. . . . .1 Plugin contributions . . . . .1 Eclipse RCP architecture . . . . . .

. . . . . . . . . . . . .4 The Business Layer 6. . . . . . . . . .7. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2. . . . . . . . . . . . . .1 Planning phase . . . . . . . . . . . . 7. . . . . 6. . . . . . . . . . . . . . . . . . . . . 7. . . 7. . . . . . . . 7. . . . . . . .6 2nd iteration . . . . . . . . . . . . . . . . 7. . . . . . . . . . . . . . . . . . . . . . . . . 7. 8 Conclusion 9 References A List of abbreviations B Attendance Tracker user manual C Attendance Reporter user manual D Installation guide for developers E CD contents . . . . . . . . . . . . . . . . . . . . . . 7.7.3 Evaluation phase . . . . 6. . . . . . . . . . . . . . . . . . .2 The Designer Service 7. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5 1st iteration . . .1 Design decisions . 7. . . . . . . . . . . . . . . . . . . . . . . . . . . . .2 Development phase . . . . . . 7. . .7 3rd iteration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.8 4th iteration . . . . . . . . . . . . . . . . . 7. . .2. . . . . . .1 Used tools and technologies . . .3 Service layer . . . . . . . . . . . . . . . . . . . . 7. . 7. . . . . . . . . . . . . . . . . . . . . . . . . . . . .5. . . . . . .6. . . . . . . . . . . .3 Exploration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2 Application layer . . . . . . . . . .6. . . . . . . . . . . . . . . . . . . . . .6. . . . . . . . . . . . . . . . . . . . . . . . 7. . . . . . . .4 Release planning . . . . . . . . . . . . . . . . x . 7. . . . . . . . . . . . . . . . . . . . .1 User Interface layer 6.1 Planning phase . . . . . . .3. . . .3 The Reporter Service 7. . . . . . . . . . . . . .1 Planning phase . . . .6 Layered architecture 6. . . . . . . . . . . . . . . . . . . . . . .7. . . . . . . . . . . . . . . . . .5. . . . . . . . . .2 Getting started . . . . . . . . . .3 Evaluation phase . . . . . . . . . . . . . . . . . .6. . . . . . . . . . . . . . . . . . . . . . . .6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1 User stories . . . . . . . . . 33 34 34 35 35 36 37 37 38 38 39 42 42 42 43 46 47 47 47 48 50 52 52 52 53 53 56 56 57 59 61 63 67 71 73 7 Application realization 7. . . . . .5. . . . . . . . . . . . . . . . . 7. . . . . . . . . . . . . . . . . . . . . . . . . . .2. . .3 Evaluation phase . . . . . . . . . . . . . . . .2 Development phase . . . . . . . . . . . . . . . .5 Persistence layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7. .6. . . . . . . . . 7. . . . . . .2 Development phase . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Hibernate object life-cycle [1] . . . . . . . . . . Workbench window . . . . . . . . . . . . . . . . IElement implementations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Comparison of AWT/Swing and SWT/JFace architectures .connection wizard . . . Designer Service sequence diagram . . .1 Attendance Reporter . . . . . . . . . . . . . . . . . C. . . . . . . . . . . . . . . . . . . . . . . . .main window . .1 4. . . . . . . . . . . . . IDesign implementations . . . . . . . . . . . . . . . Extreme Programming planning/feedback loops [6] . . .2 7. . . . . . . . . . . . . . . . . . . . . . .1 2. . . . . The planning game . . . . . . . 3 8 11 12 14 20 25 31 34 38 44 45 48 49 50 51 53 54 55 55 63 64 68 69 B. . . . .2 3. . . . . . . Attendance Reporter prototype .6 7. . .main window . C. . . . . . . . . . . . . . . . . . .4 7. . .5 7. . . . Phases of Extreme Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . .administration dialog . . . . . . . . . . . . . . . . . . . . . . .1 Attendance Tracker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3 7.List of Figures 2. . . . . . . . . . . . . . . . . . . . . . . . . .2 Attendance Tracker . . . . . .2 Attendance Reporter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1 6. . . . . . . . . . . . . . . Model-View-Controller . . . . . . . . . .10 7. . . . . . . . IParameterEditor implementations . . . . . . . Attendance Tracker business objects .3 4. . . . . . . . . . . . . . . . . . B. . . . . . . . . . . . Attendance Tracker prototype .2 3. . . . . . . . . . . . Reporter Service sequence diagram . . . . . . SWT architecture . . . . . . Layered architecture . . . . . . . . . . . . . . . . . . . . xi . . . . . . . . . . . . . .1 3. . . . . . . .1 7. . . . . . . . . . . . . . . . . . . . .2 5. . . . . . . . .1 7. . . . .8 7. . . . . Attendance Reporter business objects Report life-cycle . . . . . .11 Eclipse platform architecture .9 7. . . . . . . . . . .7 7. . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . User stories (2/2) . . . . . . . . . . . . . . . . . . . . . . . . . . 39 40 40 41 41 41 52 56 xii . Changed user stories after 2nd iteration Changed user stories after 3rd iteration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6 7. . . . . ’Browse work records’ stories . .3 7. . . . . . . . . . . Stories separation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2 7. . . . . . . ’Predefined reports’ stories . . . ’Create parametrized report’ stories . .7 7. .8 User stories (1/2) . . . . . . . . . . . . . . . .1 7. . . . . . .5 7. . . .4 7. . . . . . . . . . . . . . . . . . . . . . . . .List of Tables 7. .

enterprise sized systems can be designed. Its responsibility is to allow creation of rich customizable statistical reports in an easy manner. thus making the process easier and more productive. building and testing a code. Since the applications store data into relational database. and the project can be easily implemented and easy to maintain in the future. The framework is based on Business Intelligence and Reporting Tools (BIRT) that is a Java open tool with reporting capabilities. programmers can focus on the specific requirements of their application instead of wasting time developing something already achieved. the RCP applications are easily manageable and extendable. I’m introducing a layered architecture as a pattern that splits the application functionality into distinct layers so that each of them covers some major aspect of the system. ORM frameworks provide mapping between objects and records of the relational database and they represent a fast and effective way of how to build database applications with a minimum of effort (after you have learnt how to use it). Thanks to Eclipse plugin nature. By following these rules. XP’s mission is to speed up the development process in a maximum possible way such that all customer needs are satisfied. deploying and managing software across the lifecycle. The goal of this work was to design and develop applications based on Eclipse RCP by utilizing the Extreme Programming (XP) methodology. Eclipse itself was created by utilizing principles of Extreme Programming and includes features that add agility to any development process. application goals are achieved. Eclipse platform offers to developers SWT and JFace libraries which allow the development of the Java applications that closely match native applications in both ”look and feel” and also in responsiveness.CHAPTER 1. Eclipse. the development team can proceed faster and final product will suit the customer’s needs as much as possible. tools and runtimes used for building. the components of layered architecture can easily be reused across other systems with just a minimum of effort. In the practical part of this paper I proceed step-by-step through the development of two RCP based applications (Attendance Tracker and Attendance Reporter) by utilizing principles of XP methodology. The significant part of the work focuses on design and the implementation of the reporter framework. besides powerful IDE. Moreover. Eclipse IDE contains many tools that support agile development while writing. to be able to access data in the database. INTRODUCTION 1 1 Introduction Eclipse traditionally presents an Integrated Development Environment (IDE) comprised of many frameworks. . The framework eliminates some of the BIRT’s drawbacks and makes it more suitable to my application’s needs. By using this pattern. the iteration planning process and continuous testing. By using a common framework for developing business applications. can also be used as Rich Client Platform (RCP). Moreover. I decided to utilize Hibernate as my primary ORM framework. RCP introduces to the community of developers. the scalable platform that represents an outstanding base for any desktop application that developers can extend to construct their own applications. It is gaining widespread acceptance in the commercial as well as the academic sector and has millions of satisfied users all over the world. Extreme programming puts the accent mainly on communication with a customer.

however. When designing business applications. Eclipse is gaining widespread acceptance in the commercial as well as the academic sector. Multiple development teams at the Ames Research Center and Jet Propulsion Laboratory are using the Eclipse RCP for the development and integration of their tools in a way that will enable planning mission operations more efficiently. Eclipse platform offers to developers SWT and JFace libraries. Essentially. the 3.2 CHAPTER 2. It’s very likely that in the future. Over the last few years. The members of the Eclipse community recognized that many elements of the Eclipse IDE could be utilized in non-IDE applications and made hacks to the Eclipse code. Unlike Swing components. programmers could use the elegance of the plug-in architecture and the responsive and native-looking user interface. and it has the significant support of the leading companies and organizations in the technology field. The RCP has also become the main development platform for a group of development teams within NASA working on the project called Ensemble. you still work with platform independent java code and every native code is transparent to you. programmers can focus on the specific requirements of their application instead of wasting time developing something already achieved. which are written entirely in Java. many new consortiums will build around the RCP as other organizations decide to centralize their resources and share the responsibility for things in common contained in their programs. From the programmers’ point of view. which are alternatives to Sun’s Java libraries. While you might traditionally think of Eclipse as one of the finest IDEs for software development.g. the Eclipse project has grown significantly and developed into a powerful platform. commercial-quality industry platform for the development of highly integrated tools. SWT widgets use native code for each platform thus it’s really difficult for end users to distinguish between native and SWT application. The other RCP advantage is that it can run everywhere.0 release of Eclipse has exceeded the scope of the platform’s importance and introduced the development community to the Rich Client Platform (RCP). when IBM released the source code from Websphere Studio Workbench and founded the Eclipse Consortium to manage the continued development of this platform. The main aim of Eclipse has been to develop a feature-rich. In general we can say that as long as you can find Java Virtual Machine with the J2ME Foundation libraries or greater (e. ECLIPSE PLATFORM 2 Eclipse platform The Eclipse project was first introduced in November 2001. By using a common framework for developing business applications. . Eclipse RCP represents one of the most successful initiatives from the world of application development in a long time. J2SE). then you should be able to run the application without problems. the RCP provides a generic Eclipse workbench that represents an outstanding base for any desktop application that developers can extend to construct their own applications. AWT and Swing. The outcome of their work has been the Rich Client Platform. robust. They allow the development of the Java applications that closely match native applications in both ”look and feel” and also in responsiveness.

Equinox is an implementation of the Open Service Gateway initiative1 (OSGi) specification. he uses a plugin for that. ECLIPSE PLATFORM 3 2. By the integration of OSGi. the new version based on modular Java runtime called Equinox [5] was introduced. Except for a small runtime kernel. plugins were fully managed by a small runtime layer responsible for their loading and activation. When the developer wants to add new functionality to the environment.CHAPTER 2. OSGi framework has improved the portability of Eclipse across many operating system platforms and provided compatibility with a number of managed execution environments. For instance you can easily extend your RCP application for update or help capabilities by adding corresponding plugins.0.1: Eclipse platform architecture The central part of the diagram is the Eclipse RCP that is formed by a number of plug-ins residing on a Java Runtime Environment (JRE) layer. so new features can be added not only easily but seamlessly. The next section focuses on description of key components of Eclipse RCP. This design makes Eclipse very extensible. notably the ability to dynamically add or remove plugin and more robust security model. You can freely modify this set itself (as well as any other plugin set) to suit your needs as long as the corresponding plugin interdependencies are satisfied. Starting with version 3.1. The RCP plugin set is the base of every RCP application. car dashboard computers. 2. set-top boxes and so on .1 Figure 2.1 OSGi framework In the first implementations of Eclipse.1 Eclipse RCP architecture The most powerful feature of Eclipse is the concept of plugins. Eclipse gained the infrastructure for many new features. The platform provides a well-defined way for plugins to work together. The structure of Eclipse platform is shown in Figure 2. everything in Eclipse is a plugin or a set of related plugins and it is a base building block of every Eclipse driven application. The modularity of Java is in OSGi captured by elements 1 OSGi original mission was to develop Java components and service model for building embedded devices such as residential gateways.

jar. The manifest file (usually called MANIFEST. lib/asm-attrs.core. lib/hibernate-annotations.sw.attendance. Let’s look at the structure of the manifest file in more detail. It can be done by hooking start() and stop() methods and 2 We can think of bundles as of plugins . Basically. cz. lib/hibernate3.jar. CHAPTER 2.sw.9.core. cz. lib/commons-logging-1.jar.to The first section of manifest describes bundle’s name. it extends the JRE functionality and provides more sophisticated control of the code represented by bundles. cz.core. thus bundles can be loaded and unloaded any time. Bundle localization entry tells the framework what the name of localization file is and where it can be found. The OSGi architecture is fully dynamic.0.3.3. Bundle-ManifestVersion: 2 Bundle-Name: Core Plug-in Bundle-SymbolicName: cz. In our case it is plugin.services.attendance.runtime.core. The bundle activator is the main plugin class and it is responsible for performing initialization and cleanup events if required. Require-Bundle: org.attendance.jar.attendance.4 called bundles 2 .sw.7. thus the bundle is self-describing.ActivatorCore Bundle-ClassPath: lib/antlr-2.0 Bundle-Localization: plugin Bundle-Activator: cz. OSGi sets the standalone classloader to every bundle as well as dynamically constructs bundle’s classpath based on dependences in its manifest file.jar. lib/c3p0-0.jar.1.sw. cz. lib/cglib-2. ECLIPSE PLATFORM Every bundle has a form of a standalone JAR file.MF) resides in bundle itself. .bo. lib/asm.sw.jar.attendance.properties file. OSGi framework is responsible for managing this bundle and its code.sw.sw.core Bundle-Version: 1.jar.6rc1.0.1.core. lib/commons-collections-2.eclipse.attendance.1.core. It can also contain additional human-readable descriptive values.1-jdk1.common Export-Package: cz. symbolic name and version that together uniquely identify the bundle.jar. which contains information about bundle and the list of its dependencies.4.

2. This way it allows other bundles to be able to reference the classes in the package. However. Any plugin. What Eclipse allows you. it is dynamically processed and a unique classpath is assigned to it to tell it exactly where its prerequisite code is situated. The runtime is responsible for managing plug-in resources. is to explicitly modify these dependencies and thus manage them efficiently. it is possible to add the version ranges and other markup to this header. it must .CHAPTER 2. the Runtime still remains a home of the several key mechanisms such as the application model or extension registry. for example. In the Require-Bundle header. 2. the role of the Runtime was to manage the lifecycle of a plugin within a workbench in all aspects.0 version of Eclipse. if the bundle provides some functionality to the rest of the system it must expose the corresponding API by exporting the API package in the Export-Package section. But as we already have seen in the preceding section the plugin model is now fully managed by the Equinox framework. Immediately after execution. from which every plugin can find out at runtime the information about other plugins (for example which plugins wish to extend it). Packages that are not present in the list are implicitly hidden in the other bundles. the Eclipse Runtime will first discover all of the plugins that are available to it and use this information to create a global plugin extension registry.1 Plugin contributions The Eclipse’s extensible nature and the concept of plugins are the key factors that made Eclipse such a successful platform. bundle expresses all of the plugins that it depends on. it means a platform-independent view of operating system files and folders. Since the number of plugins can be potentially large in some applications. Bundles that don’t comply with the prerequisites are not resolved and are not allowed to be run. The original Java application classpath is ignored in this case and a new classpath is entirely computed from the dependencies expressed in the manifest file. To better refine the dependencies. because the plugin in charge of workbench defined an extension point. plugins (as well as extensions) are not loaded until the moment they are actually needed. It is a good practice to specify ’. Finally. For a plugin to be able to contribute to other’s plugin extension point.1. through which to do so.2 The Platform Runtime Prior to the 3.’ at the end of the list to notify that the bundle’s code is also at the root of the bundle’s JAR itself.1. 5 The classpath entry identifies where the bundle’s code is located inside the bundle itself. can add a view to the main workbench. to reduce start-up time and resource requirements. Every plugin can define extension points that are the places where other plugins can add their functionality. ECLIPSE PLATFORM execute the wanted actions. Equinox resolves the dependencies between them and bind them together. but because they are implicitly defined in the code. thus there is no more need to define the global classpath variable. When a bundle is eligible to run. Given a set of bundles. You should be aware of the fact that interdependencies between bundles are there not because of Eclipse. 2.

exsd"/> It says.1.eclipse. Extensions as well as extension points are extensively used throughout Eclipse. They are defined in an XML-based file called plugin. ECLIPSE PLATFORM define an extension.exsd XML file.2.ui plugin looks as follows: <extension-point id="views" name="%ExtPoint. It’s important to distinguish between extension point and extension. 2.2 Applications and Products As we already know from the previous section.6 CHAPTER 2. Extensions are loaded lazily and therefore no code is loaded until it is actually needed.views"> <view allowMultiple="false" class="cz. Such a behavior enables various approaches to be used for presenting.eclipse.xml of the org.ui. the definition of views extension point contained in the plugin.TitleAreaView" id="cz. we say that we are going to extend the views extension point that is provided by the org. Eclipse is build entirely from the plugins. The mechanism of extension points allows different kinds of data to be loaded through the extensions points (not just a code as one would expect). And this is exactly what RCP allows us to do .sw. This way we build entirely new application that .sw. For example if our plugin wish to contribute to workbench views it has to define the following extension: <plugin> <extension point="org. Eclipse provides the user friendly wizards that enable programmer to define the extension and extension points in a comfortable way. Even the workbench itself is loaded as an extension.attendance.views. Such an aproach minimalize the dependencies between extensions and plugins and minimalize consequences resulting from the future modifications.views" schema="schema/view.ui. For example in the previously defined example the TitleAreaView class will be only loaded when a user use it. Be aware of the difference between ’extension point’ as the definition of contribution (extension) and ’extension-point’ as a definition of an extension point. An extension-point declares the availability of a plugin’s functionality to other plugins in contrast with an extension that uses a previously defined extension-point of some plugin to extend its functionality. scoping and filtering contributions.views. that the views extension point is specified by the views.ui.attendance.titleareaview" name="Title Area View"> </view> </extension> </plugin> In the extension definition.to run a completely different application on the top of the platform core runtime just by defining the applications extension point.eclipse. On other hand.xml which is located at the root of the plugin’s directory.ui plugin and we want TitleAreaView to be a definition class of the view served by this extension.

JFace The JFace toolkit is a platform-independent user interface API that extends and interoperates with the SWT. It may consist of one or several workbench windows. When the application exists. It provides the UI building blocks that make Eclipse applications easy to write. This class defines and initializes user interface layout and set up required application services. ECLIPSE PLATFORM is equipped by all of the platform functionality. you can specify which application to run. The Eclipse workbench has a clear hierarchical structure.1. These toolkits include: Standard Widget Toolkit (SWT) SWT provides a platform-independent API that is tightly integrated into the operating system’s native windowing environment. unlike most Java applications. Similarly to an application.. wizard and dialog components. image and font components. When you run Eclipse. scalable. the product is specified by an extension.3 SWT/JFACE If you look at the source code that makes up the Eclipse Platform.2).4 The Generic Workbench The workbench is Eclipse’s graphical user interface. After the Runtime start. the project produced two user-interface toolkits that can also be used outside of the Eclipse project. During the development of the Eclipse Platform. This toolkit overcomes many of the design and implementation trade-offs that developers face when using the Java Abstract Window Toolkit (AWT) or Swing. This is the case because it is built using SWT and JFace. . configuration files or preferences). 7 An application extension point announces to the Eclipse Runtime where the entry point of the application is. These pages are used to display the various perspectives of a workbench window (see Figure 2. it looks and feels like a native application. the application is under control of Eclipse. SWT’s approach provides Java developers with a cross-platform API to implement solutions that ’feel’ and response like native desktop applications. Only one page per workbench window is active and visible to the end user at a time.g. 2. however. 2. This library provides a set of components and helper utilities that simplify many of the common tasks in developing SWT user interfaces. text manipulation. Many applications and many products can be defined in any given Eclipse configuration. the branding context such as splash screen or window icons as well as customization elements (e. and extendable.1. Workbench pages offer a series of methods for managing editors and views. We will look at these toolkits closer in chapter 3 (page 11). easy to use. The concept of products is a step above applications. It is used entirely throughout eclipse and is necessary for all GUI plug-ins.CHAPTER 2. This toolkit includes many utility classes that extend SWT to provide data viewers. you notice that the Java standard windowing toolkits are not used. only one product and corresponding application may be running at a time. it finds and runs the specified application class. It is possible to define more than one application extension. One of the workbench’s notable features is that. Eclipse shuts down. Once invoked. Each workbench window can own one or several workbench pages. It adds to an application.

What the editors and views are displaying will vary.1. allowing you to switch tasks without having to change windows.2: Workbench window 2. a close icon. an editor shows the main content of your application. Think of a perspective as a way of looking at your work that is optimized for a specific kind of task. Of course. several Java editors). and an area for the content. The titlebar will show a tab for each view. applications are free to define their own ones. It allows you to read and/or write a particular file type. such as the Resource perspective or the Java perspective. and you will usually have more than one of the same type of editor open (for example. ECLIPSE PLATFORM Figure 2. and toolbars.1. or draw a diagram. 2.3 Editor Typically. It is also possible to save or revert an editor’s contents in contrast with .4. The Eclipse platform provides some predefined perspectives. Let’s look more closely at perspective main components: views and editors. a toolbar. Eclipse comes with dozens of different views that are available for your application. It can be used to edit a file. along with their arrangement within a particular workbench that relate to a specific task or workflow.1. open new views. editors don’t have toolbars.4. Most views have a titlebar that includes the icon and name of the view. But unlike views. Multiple views can be stacked together in the same rectangular area.1 Perspective An Eclipse perspective defines a set of views. For example. you may rearrange windows. editors. manipulate a bitmap. Editors share many characteristics with views. based on the kind of perspective in use. 2. and so on. As you perform a task. in the Eclipse IDE. You can have multiple perspectives in the same window.8 CHAPTER 2.4. the Java perspective contains views for editing Java source files.2 View A view is a metadata presentation of information on the workbench. Your arrangement is saved under the current perspective. but only one view can be active at a time. while the Debug perspective contains views for debugging Java programs.

deployment. You can also collapse a view to an icon on the edge of the window (fast view). monitoring. there is no better way to take advantage of these libraries. and management of software designed around a Service Oriented Architecture (SOA). Test and Performance Tools Platform (TPTP) The Eclipse top level project whose mission is to build a generic. SOA Tools Platform project (STP) The mission of STP project is to build frameworks and exemplary extensible tools that enable the design. WTP includes the following subprojects: Web Standard Tools (WST). extensible. BEA Weblogic and IBM WebSphere). standards-based tool that would offer world-class test and performance tools. It supports a number of servers (DB2. co-browsing. each of them has a purpose and if your plugin plans to provide similar functionality. Dojo and Rico Ajax toolkits are supported. A good source of inspiration about RCP programming is [13] and [3]. Sybase. and it is possible to drag views outside of the main Eclipse window (tear-off views). configuration. views. ECLIPSE PLATFORM a view where this is not allowed. Don’t waste time by reinventing the wheel. and editors. real-time collaborative editing. Eclipse Communication Framework (ECF) This framework supports the development of distributed Eclipse-based tools and applications. Informix. standards-based tools platform for producing Web and Java EE applications.). assembly. Java EE Standard Tools (JST) and Java Server Faces (JSF) tools. file sharing. 2. you can arrange the views around the editors. The Ajax Tools Framework (ATF) Ajax is an emerging technology that is likely to be important in the foreseeable future. Eclipse matured into a powerful platform and became the base for many successful projects that brings new functionality to this platform. Examples include instant messaging. and they can’t be mixed with views. MySQL etc. TPTP provides monitoring tools. Web Tools Platform project (WTP) This open source project is designed to provide a generic. such as the Web Tools Platform and Data Tools Platform. however. STP is a complement to other Eclipse projects.2 Eclipse platform tools During the last few years. The only restrictions are that editors have to stay in their own rectangular area. 9 Views and editors can be shown side by side or stacked on top of other views and editors. It is almost impossible to fully understand all of these technologies. it’s up to the individual RCP application to decide how to expose these to the end-users. WTP provides a rich set of tools and features for open source and commercial products (Apache Tomcat.CHAPTER 2. As with many things related to perspectives. user presence etc. . extensible. However. View as well as editor can be easily moved by simply clicking on its titlebar and dragging it to a new location. Data Tools Platform project (DTP) DTP’s goal is to provide world-class support for relational databases. SQL Server. multi-user chat. Currently. Oracle.

C/C++ Development Tools (CDT). tracing tools and profiling tools. With BIRT. and standards implementations. especially those based on Java and J2EE. . Business Intelligence and Reporting Tools project (BIRT) Reporting system for desktop and web applications. For more detailed description. Orbit. It provides a unified set of modeling frameworks. Parallel Tools Platform (PTP) and Eclipse Visual Editor Project (VE). you can add a rich variety of reports to your application. The Eclipse Device Software Development Platform (DSDP) DSDP is the project dedicated to providing an extensible. PHP Development Tools (PDT). Eclipse Tools Project This project covers the development of following subprojects: AspectJ. tooling. standards-based platform to address a broad range of needs in the device software development space.10 CHAPTER 2. AspectJ Development Tools (AJDT). ECLIPSE PLATFORM performance and manual testing tools. see [15] The Eclipse Modeling Framework (EMF) EMF is a modeling framework and code generation facility for building tools and other applications based on a structured data model. Graphical Editor Framework (GEF) Project. COBOL IDE.

It provides API for building simple graphical components such as labels. This ensures that widget has native a ’look and feel’ on each platform. but delegates the task of providing specific implementation of component to the operating system. SWT is a set of widgets that accesses the native controls through the Java Native Interface2 (JNI) and only those few controls that are not present on a particular OS are emulated (a good example Although the performance of Swing has improved with Java 1. To achieve this goal. extensible GUI library. Sun decided to abandon native widget interfaces and developed its own. 2 Programming framework that allows Java code running in the Java virtual machine to call and be called by native applications and libraries written in other languages.CHAPTER 3. This approach helped Java become more useful in terms of UI but a drawback was that the controls did not match the look of the platform on which they run and the performance was also much worse compared to the native implementations1 . AWT isn’t creating widget on its own. crossplatform. rather than delegating to the OS. C++ 1 . Figure 3.4. ECLIPSE USER INTERFACE FRAMEWORK 11 3 Eclipse user interface framework One of the most important common facilities provided by the Eclipse framework is the portable native widget user interface called the Standard Widget Toolkit (SWT). IBM’s goal was to create a GUI toolkit that would look and behave like the natural OS widgets and perform with the same speed. The problem with AWT is that Sun (the author of AWT) only implemented the widgets that were common among all platforms that supported Java. lists and menus. Standard Widget Toolkit (SWT) SWT is something of a hybrid of the two previous approaches. Swing To solve the problem of AWT and to provide Java with a more powerful. they wrote everything in Java. such as C. text boxes. Let’s compare these frameworks in more detail. SWT was developed by IBM as a replacement toolkit for the Abstract Window Toolkit (AWT) and Swing. but it’s not suitable for creating full-featured user interfaces.1: Comparison of AWT/Swing and SWT/JFace architectures Abstract Window Toolkit (AWT) AWT is first of the Java GUI frameworks. emulated widget library officially known as the Java Foundation Classes (JFC) or Swing. Java applications that rely on Swing are still unable to match native applications in presentation quality and responsiveness. AWT is therefore sufficient for developing small user interfaces and decorations for Java applets.

One of the most important jobs the Display does is to translate the native platform’s events into those suitable for use within SWT and vice versa. thus making it possible to run with older JREs or restricted class libraries on handheld computers. for instance. The first is the top-level window of your application.1 Standard Widget Toolkit SWT is built up of three basic components: A native library that talks to the OS.12 CHAPTER 3. Figure 3. . upon which the rest of your GUI is built. Shells are used for two different types of windows. The Java native methods in SWT are completely different and specific to each native window system. dialog boxes. 3. a Display class that acts as an interface through which the SWT communicates with the GUI platform using JNI and a Shell class that acts as the top-level window of the application. which can contain widgets (another term for controls and composites ). Shell is created as a child of the Display class. In this case.2 shows the structure of SWT components. The advantage of this concept is that. because of the close integration with the host operating system. In this case. AWT defines a common set of Java native methods. • Shell is basically a window the user sees that is controlled by the operating system’s window manager. but is emulated under Linux). and these methods are then implemented on each system. Shell is created as a child of the Shell upon which it is to appear. Although both AWT and SWT are Java native UI toolkits. All the logics are expressed in Java code for SWT.2: SWT architecture • Display represents the top level manager that carries out all the important tasks and saves you from dealing with them. The other type is a window that is the child of another window. the ”look and feel” and the responsiveness of SWT-implemented applications are no different than in native applications. SWT also makes minimal use of Java class libraries. ECLIPSE USER INTERFACE FRAMEWORK that demonstrates this is the tree widget that exists as a native component under OS Windows. Figure 3. the implementations of them are quite different.

CHAPTER 3. ECLIPSE USER INTERFACE FRAMEWORK

13

• Widget refers to a GUI object that can be placed inside another widget. It’s either control or composite. Control is a GUI item that has an operating system counterpart (for example a button, text, area or menu) whereas composite is a widget that can have children (for instance toolbar or tree). The best example is the canvas, which you use to build up complex user interfaces with the help of sub-canvases using different layouts. The SWT architecture was designed to conform the platform application structure, so it has an important effect on the creation of widgets and disposal of resources. When you’re creating a widget in SWT, you need to take into account how it is created in the underlying operating system. Every control has a similar constructor that takes two arguments: the first specifies what the parent widget is, and the second specifies what the style of the widget should be. According to the above mentioned principle many underlying operating systems work. When the SWT object is created, the equivalent operating system object is also created, and it needs to know what the parent is. This also applies to the style3 settings for some widgets. Once they are created, the style cannot be changed. One of the few SWT’s drawbacks is that you have to be more careful about how you use operating system GUI resources, because only a limited supply is available. One of the great features of Java is that it has a built-in garbage collection mechanism, which frees Java developers from allocating and freeing objects. When you program using SWT, you can still enjoy this feature, except that you have to manage the operating system resources yourself. Therefore, when you create a resource-based object in SWT (for instance Color, Cursor, Font, or Image), you must remember to dispose of it when you are done. If you don’t dispose of unused resources, a resource leak will occur and you will end up in a situation where you will neither be able to create any more objects, nor any other application running in the operating system. However, the issue of resource management has been solved very well by SWT and there is no need to make any great effort to overcome this.

3.2

JFace

JFace is a Java application framework based on SWT. The goal of JFace is to provide a set of advanced components that make it easier to write professional Java-based GUI applications. The functionality provided by JFace framework can be split into following categories: Image and font registries Registries help the developer to effectively manage operating system resources. Dialogs and wizards Set of standard and derived dialogs and wizards. Progress reporting Reporting functionality for long-running operations. Action mechanism JFace action is represented by command that can be executed by the user via menus, buttons, or toolbars. Each action has defined its own UI properties, such as label, icon and tooltip that present the actual widget in the workbench.
3 A style is a hint to the OS about how a widget looks. For instance, when you’re creating a Button, the style defines what type of button it is: radio, push, checkbox, and so on.

14

CHAPTER 3. ECLIPSE USER INTERFACE FRAMEWORK

Viewers and editors Model-based adapters for some SWT widgets. These widgets have common behavior and provide higher level of abstraction from the user point of view. Although SWT provides a direct interface to the native platform widgets, it is limited to use simple data types as strings, numbers, and images. This is fine for a large number of applications, but it represents severe problems when dealing with object-oriented data that needs to be presented in lists, tables, trees, and text widgets. For that reason JFace offers programmers the Model-View-Controller (MVC) approach when working with these widgets.

Figure 3.3: Model-View-Controller

The MVC pattern is a classic design pattern. It separates the application object (model) from the way it is represented to the user (view) and from the way in which the user controls it (controller). Most MVC classes can be found in JFace. For example, to use a table in JFace, you still create the table widget, but you don’t put data into it. Instead, you give it your content (or model) provider class and your display (or view) provider class. The table then calls your provider class to determine both content and how to display that content. The MVC approach requires much more time for developers to master, but it is more maintainable and extensible. However, you still can use the traditional approach, which is easy to learn and the basic knowledge acquired from the traditional approach helps the developer understand the mechanisms behind the MVC. In the following part, I will demonstrate the use of the Tree component utilizing the traditional as well as the MVC approach. I’ll use the data model from Report Explorer class (used in Attendance Reporter) that is defined as follows:

public class TreeNode { private TreeNode parent; private List<TreeNode> children; private int type; private Object object; public TreeNode(int type, Object object, TreeNode parent) {

CHAPTER 3. ECLIPSE USER INTERFACE FRAMEWORK this.type = type; this.object = object; this.parent = parent; } public List<TreeNode> getChildren() { return children; } public void setChildren(List<TreeNode> children) { this.children = children; } public Object getNodeObject() { return object; } public int getNodeType() { return type; } public TreeNode getParent() { return parent; } }

15

The TreeNode represents a node of the tree that can be either category (’Templates’ or ’Favorite Reports’) or a report template or a concrete report. To distinguish which type of object the given node encapsulates, we use the nodeType property. Every node can contain children. For example, report template node contains the concrete reports. To make this more clear, let’s create a new model and fill it up with demo data. List<TreeNode> nodes = new LinkedList<TreeNode>(); TreeNode category = new TreeNode(CATEGORY, ObjectCreator.createCategory("Favourite Reports"), null); nodes.add(category); category = new TreeNode(CATEGORY, ObjectCreator.createCategory("Templates"), null); { TreeNode template = new TreeNode(TEMPLATE, ObjectCreator.createTemplate("Monthly attendance"), category); { TreeNode report = new TreeNode(REPORT, ObjectCreator.createReport("Alena Svobodova"), template); report = new TreeNode(REPORT, ObjectCreator.createReport("Michal Grznar"), template); } template = new TreeNode(TEMPLATE, ObjectCreator.createTemplate("Daily attendance"), category); template = new TreeNode(TEMPLATE, ObjectCreator.createTemplate("Summary"), category); { TreeNode report = new TreeNode(REPORT,

16

CHAPTER 3. ECLIPSE USER INTERFACE FRAMEWORK ObjectCreator.createReport("March 2007"), template); report = new TreeNode(REPORT, ObjectCreator.createReport("January 2007"), template); }

} nodes.add(category); Our model represented by list nodes contains the top-level categories and corresponding templates containing the reports. The following snippet shows how it would be possible to create the Tree component based on previously created model using the traditional approach. The Tree widget comes from SWT and it is handled in a similar fashion to tree components defined in concurrent toolkits. private Tree tree; public void createPartControl(final Composite parent) { tree = new Tree(parent.getShell(), SWT.NONE); for (TreeNode node : nodes) { addNode(null, node); } } /** * Recursively adds a node to the tree. */ private void addNode(TreeItem parentItem, TreeNode node) { TreeItem item = null; if(parentItem == null) item = new TreeItem(tree, SWT.NONE); else item = new TreeItem(parentItem, SWT.NONE); item.setData(node.getNodeObject()); switch (node.getNodeType()) { case CATEGORY: item.setText(((ICategory)node.getNodeObject()).getName()); break; case TEMPLATE: item.setText(((ITemplate)node.getNodeObject()).getName()); break; case REPORT: item.setText(((IReport)node.getNodeObject()).getName()); break; default: item.setText(""); } List<TreeNode> children = node.getChildren(); for (TreeNode childNode : children) { addNode(item, childNode); } }

if (node. we first need to implement Content provider and Label provider interfaces. ECLIPSE USER INTERFACE FRAMEWORK 17 The implementation of this method is quite straightforward. Object newInput) { // } } . we implement interface of ITreeContentProvider that is commonly used in trees. Viewer provides mechanism that allows us to work with a tree in a more abstract way. but the power of this approach is in its flexibility especially in enterprise applications. } public void dispose() { // } public void inputChanged(Viewer v. return node.toArray().toArray(). } public boolean hasChildren(Object element) { TreeNode node = (TreeNode)element. It’s important to note that in this case we are working with JFace’s TreeViewer rather than directly with SWT Tree. return nodeList. a tree item is created under the root of the tree and similarly for other model nodes. } public Object[] getElements(Object inputElement) { if (inputElement == null) { return null. In our case.getChildren(). Content provider is used to map between model object or a collection of model objects and the internal list structure that is needed by the viewer itself. similarly to other JFace components. return null. class ReportExplorerContentProvider implements ITreeContentProvider { public Object getParent(Object element) { TreeNode node = (TreeNode)element.getChildren() != null). Object oldInput. the corresponding tree items are created under parent items.getChildren() != null) return node. return (node. } List<TreeNode> nodeList = (List<TreeNode>)inputElement.getParent().CHAPTER 3. } public Object[] getChildren(Object parentElement) { TreeNode node = (TreeNode)parentElement. To have the viewer work. For each of the root categories. The Model-View-Controller code is not so straightforward and might look a little heavyfooted.

However. the MVC approach should be definitely a preferred way. we call the viewer’s setInput method. ECLIPSE USER INTERFACE FRAMEWORK Next. More detailed information about SWT/JFace libraries can be found in [16]. } } We will associate the viewer with the content provider using setContentProvider method and with the label provider using setLabelProvider method. viewer. to start delivering the content of a model to the tree.setContentProvider(new ReportExplorerContentProvider()).getName(). .getNodeType()) { case ReportExplorerTree. the label provider is used to map our model objects into one or more images and text strings.setInput(nodes).18 CHAPTER 3. public void createPartControl(final Composite parent) { viewer = new TreeViewer(parent. to signal the provider. case ReportExplorerTree. Finally.NONE). class ReportExplorerLabelProvider extends LabelProvider implements ITableLabelProvider { public String getText(Object element) { TreeNode node = (TreeNode)element. viewer. } public Image getColumnImage(Object element. } We have seen two approaches that can be considered when dealing with a tree component. switch (node. } public String getColumnText(Object element.getNodeObject()).getName().setLabelProvider(new ReportExplorerLabelProvider()). int columnIndex) { return null. we will focus on the label provider. if the application needs more advance support. Since the content provided produces raw objects.REPORT: return ((IReport)node.getName(). } return "". int columnIndex) { return null. The maintenance and scalability of your system will be much better. Basically.TEMPLATE: return ((ITemplate)node. the traditional approach is a simple and straightforward way. such as category sorting or is a part of a complex system. Generally. viewer.getNodeObject()). displayable by the viewer.CATEGORY: return ((ICategory)node.getNodeObject()). the viewer needs to question the label provider. we can say that for a simple application without extended capabilities and where future changes are not likely to occur. case ReportExplorerTree. SWT.

Stories are used instead of the large comprehensive documentation with objects and diagrams. a methodology is a set of good practices that may be repeatedly realized to produce software. You are familiarized with a problem and you have a vision how to solve it. During the development of my application I follow a pattern of Extreme Programming one of the agile methodologies. as the application grows and becomes more and more complex it is a good practice to use some of the time-tested methodologies that will ensure effectiveness of your work and reliability of your product.2 4.2.1 Pillars of Extreme Programming The Planning Game In Extreme Programming. 4.CHAPTER 4.2. testing and final integration. it is also possible to use it when there is only one developer working on a project. This type of analysis can be loosely described as the process of discovering the customer requirements. as was in my case. the project can easily be implemented and to maintain in the future. 4. where each implements stories that consist of tasks (see Figure 4. . EXTREME PROGRAMMING 19 4 Extreme Programming The development of simple application is quite straightforward. Their main aim is to help developers to satisfy customer’s needs as much as possible. In spite of the fact that extreme programming is recommended for small and middle size teams. It lays down strict or less strict rules that your project should follow. In Extreme Programming. However. We are mostly considering the business value of each story. infallibility. Each user story is a short description of the behavior of the system from the user’s point of view and it is the medium of communication between the customer and the programmer. the process of planning consists of the releases that are made up of iterations.1 Release planning In the first phase of the release planning. It does not focus just on programming but also at analysis. The author of this methodology is Kent Beck who is one of the founders of the Agile Manifesto [12]. how to speed up the development process in a maximum possible way such that all the customer’s needs are satisfied. methodology aim is to eliminate all the hassle the software project is accompanied by. In project engineering. In other words. we will be focusing on writing user stories and defining what the system needs to do to be able to define a successful product. application goals are achieved. compactness and testing because the application is small and you will have it done somehow. A number of successful methodologies have been evolving in recent years. Essentially.1). 4.1. You may think of them as of use cases but they are not the same. In the next section I’ll focus on main parts of Extreme Programming methodology and their practical use. the entire system is specified through the user stories.1 Getting Agile Some present day groups of very competitive methodologies are the Agile Methodologies. That means how valuable it is for the customer and whether it is worth implementing. You don’t have to contemplate about such facts as: code effectivity.

By keeping stories small. but with a little effort you can. because it’s very common for a customer to write a story that is hard to estimate. The stories should be such a size that you can build a few of them in each iteration. Good estimates are a kind of art. The best way to make good estimates is to look at something similar to one you have already delivered in the past and that was about the same size as the actual thing. You should start estimating as soon as you start writing stories. you ask the customer to define the user story in more details or split it into smaller ones so that it can be easier to estimate. releasing often and bringing the customer and programmer together.g. accuracy will also improve. In such a case. Cards store stories brief and make them easy to use during planning session. They should also be independent so that you can shift them between iterations in keeping with changing priorities. In this phase we estimate the difficulty of implementing each story and the speed of the implementation. You also have to take into consideration the technical dependencies and difficulty of the stories but most of the time they are less important than the value.1: The planning game The important part of release planning is the assessment of user stories. makes the final result as close as possible to the customer’s needs. . The basic rule usually is: do stories with the highest business value first to make the release as valuable as possible to the customer.20 CHAPTER 4. EXTREME PROGRAMMING A good practice is to have a pack of blank cards (e. 10x15cm) where each card represents one user story. As your experience grows. It is important that the stories are short and easily understandable by a customer. however. get good enough estimates. You will probably never be able to get the accurate numbers. The last part of release planning is about prioritizing the stories. Figure 4.

Developers often predict what they may need in the future and integrate this functionality in the code. it means that one can sign up for 5 ideal days of work in each iteration. We measure the velocity of our team and then estimate the amount of effort needed for each story.CHAPTER 4. You definitely don’t want to pass up the opportunity to learn what users really want and the increasing confidence that will come from showing people your product. you will be changing direction.2. it is important to have a feedback from users and to know if they are satisfied with the product. discussion etc. 4. It is a good practice to allow some time for creation of a good metaphor that gives a clear description of system operation to programmers and lay people. the customer decides what to do and what to defer. the system that seemed mysterious and complicated becomes clear and simple.1.2 Iteration planning 21 During each release. Later on. the team plans just a few weeks ahead. During the iteration planning. An early release often is one of the fundamentals of extreme programming. to make the best possible release by the date it is due. .2.2 Small releases It’s much more likely that as the project evolves. The goal is to select work that will maximize the business value completed by the end of iteration. You should not wait more than two months to release a version of the product. the developer spends studying new technologies. we aim to keep the system as simple as possible.4 Simple Design In Extreme programming. It can really pay off. 4. You may claim that it’s too risky. as you discover what’s easy to do and what’s not so easy. by naming the objects of the application. EXTREME PROGRAMMING 4. To make good decisions about what to do and when to do it and keep the development efficiency high. In each release cycle. a little or a lot. They include tighter estimates of the work effort than those which were provided for release planning. 4. That means. That’s why often releases absolutely should be considered in a healthy development process. you can profit from a good metaphor. The work should be planned in short iterations of between two to three weeks. If one developer has for instance velocity 5 ideal days. the stories are broken down into tasks and afterwards they are assigned to developers. but actually it isn’t.2. As a result. for example. too. The idea is to let the customer and programmers communicate clearly about what the system does and how it does it.3 System Metaphor Metaphor in Extreme Programming is the idea that each application can be described by a simple metaphor that everyone understands. The velocity of new members of the team or part time developers is almost always less than 5 ideal days. Extreme programming never does this. We can measure the velocity of individual programmers. To find out how many stories can be done in each iteration we use the term velocity that represents how much the team can do in an iteration.2. we concern ourselves only with features that are definitely needed by the customer. It explains the essence of how the program works in a way that is easy to understand. with clear objectives and good estimates. We don’t implement structures or algorithms that are more complex than we actually need. The rest of the time.

there is nothing to prevent us from releasing the tests and code into the repository. they keep the design simple and they make collective code ownership safe. After the task has been completed.5 Continuous testing and integration Continuous testing and integration are key factors in all agile development projects. Tests are the inherent part of the development process in Extreme Programming. They typically test the entire system. or a small group of classes. the job is done. The programmer should not be affected by the code already written. This way. The unit tests enable refactoring. 4. Each integration should be verified by an automated build and test to detect integration errors as quickly as possible. When the tests run at 100%.5. the fewer problems you’ll have. thus the basic rule is: write a test first and the tested code afterwards. The main idea is that developers integrate their work frequently.5.2 Acceptance tests The customer has right to see progress in the form of a properly working system.1 Unit tests Unit tests represent automated tests written by the developers to test functionality of their code.2. 4. Each unit test typically tests only a single class. the story is considered complete. this can lead to pain and suffering. beware of duplicates in the code and keep the number of classes and methods as little as possible. Prior to each integration step. The programming is also less stressful than when you are unsure whether the lastly added feature hasn’t violated your existing code. A code written like this is a delight to work with.2. If we dont’t make any tests at all and put off the overall testing before release. When all tests are successfully completed. When all of the tests have passed for a given user story. Acceptance tests (also known as functional tests ) are specified by the customer to verify that the overall system is functioning as specified. such as JUnit. usually at least once per day or more. This approach leads to significantly reduced integration problems and allows a team to develop reliable software more rapidly. This way you ensure that the produced code is much less buggy and the overall quality of the code is higher. then it is more easily modifiable and extendable. or some large part of it. It’s generally a good idea to release software many times per day and retest the integrated system every time. he writes a test for it. The main idea is that before the programmer adds a new feature. It is good practice. to have all the code covered by unit tests. To keep the design simple. 4. The less time you wait. The programmer works on just one task at a time.2. we are able to find the error that caused the system failure very quickly and effectively. he will integrate it into the actual release and run all unit tests in the entire system to make sure that his code hasn’t broken system functionality. it’s important to run all tests regularly. . After that we make just a small atomic changes and run all the tests again and so on until we are done.22 CHAPTER 4. They are typically written using a unit testing framework. we make sure that all tests are running at 100%. There are two common types of tests in Extreme Programming: unit tests and acceptance tests. EXTREME PROGRAMMING If you keep the system simple enough.

7 Pair programming Probably everyone has experienced working together with another developer on something really difficult and it’s usually a good experience. He must understand everything that is being done. and a better one than the same two programmers working on their own.CHAPTER 4. 4. team knowledge grows faster and work is more fun. This is time consuming.6 Refactoring Refactoring is the process of improving the code’s structure while preserving its functionality. let him/her drive. a human can run. so that you can try and if you don’t like it. Ideally. In the initial phase of the planning of the project. is that if you write a program today and test it after a week. Moreover. All popular integrated development environments contain tools that enable the programmer to refactor the code that is considerably increasing his productivity. the acceptance tests should be fully automated. You might be afraid to change the existing code for fear of breaking it. we don’t use pair programming only for difficult or serious problems. Each refactoring step is reversible. see [8]. She listens to what the partner is saying and takes his advice. when they are finished. In a pair of programmers. If the partner has a better idea that is difficult to express verbally or the driver is stuck. Refactoring enables you to redesign in a very comfortable and safe way. it is hard to find out how you actually wrote it and you won’t be able to quickly locate the problem. . It protects your code from duplications and uncommunicative code. 4. down. its really hard and time consuming to perfectly design a product so that there will be no need to redesign anything in the future. could consist of scripts of user interface actions and of expected results. For a concrete description of refactor techniques. so the partner can understand it. It’s easy to let yourself get stuck when you don’t really understand the code and then you lose the advantage of pair programming. The only way to move the project successfully forward is to have a strong network of tests. In extreme Programming. That’s where tests come into consideration. either using unit testing framework.2. and slows the project down. who is typing is a driver and the second is a partner. you can return it to its original state. you may feel comfortable with your changes in the code. but we use it all the time. On the other side. The partner is actively engaged and helping the driver. EXTREME PROGRAMMING 23 Another good reason for not underestimating testing and testing often. they understand the whole code instead of understanding just a part of it. It speeds up your system and you feel better because of deeper understanding of the code. he can switch roles and continue with his programming. If all tests run at 100% after refactor. A pair of programmers (working as a team on the same subject) would generate more code. both unit and acceptance that ensure that changes to the system don’t break things. however. further speeding development. It’s almost impossible. that already work. reusable components emerge from this process. There always will be. otherwise he needs to stop the process and makes things clear. minor changes made to the design. at least. Moreover. or some specialized framework designed for this purpose.2. It is a good opportunity to keep the design simple and transparent. Tests. If one of a pair of programmers is not sure of what’s being done. the driver explains what is being done.

he is able to steer the team with much more confidence and understanding because of a closer relationship between him and the rest of the team.24 4. who is working on a project. 4. and when there are bugs. This way. This can work for few days. he is also altering existing classes and recapturing code such that it suits his needs. The customer specifies his requirements using user stories. Working in pairs and collective ownership of the code is effective only until everyone uses the uniform set of coding rules. In Extreme Programming. He makes the decisions that affect his business goals and gives the developers a feedback about their work.8 Collective code ownership CHAPTER 4. But working overtime for several consecutive weeks is a clear signal that something is very wrong with the process and it certainly has an impact on the quality of the resulting code.9 Coding standards You can write a code any way you want if you are working alone but this doesn’t work in a team. everybody should use the same style for class and variable names and format code in exactly the same way. more detailed information will be needed.2. they’re easier to find and fix.2. This means that the code resides in repository that is accessible to anyone working on the project and everyone is authorized to improve anything at any time. But coding standards are not only about a nice readable format. the good readability of the code is especially important because the source code is delivered as a fundamental part of the documentation and provides examples for use and best practices. The systems that enable this are generally known as Version Control Systems. in order to meet some delivery date. user stories are described only to a level that is necessary for estimating the work. The most famous ones in the world of open source are CVS and SVN. Suddenly. 4.2. EXTREME PROGRAMMING As a programmer. The customer’s role is to provide information regarding user stories whenever there are some ambiguities. Coding standards chosen for communication also help new people to learn the system. Coding standards should be easy to remember and should come from commonly used standards for the given programming language or environment. Without any source control management it would be a really tough problem. The reason is simple: the programmers are tired and they are not productive . Once you want to start the implementation of the user story. set priorities and creates test scenarios to see whether the user stories have been implemented correctly. The customer should not only help the team but should also be a part of it. In a team. we are heading towards a problem how to tell others that their code has been changed. That’s why every team needs to have defined a coding standards that everyone is familiarized with. It can lead to a higher-quality code with fewer bugs.11 40-hour week Sometimes we are pushed to work overtime. The idea is that all the programmers own all the code. writes new classes. however. 4. Collective code ownership allows more programmers to be able to work on the same code at the same time and the team definitely cannot live without it.2.10 On-site Customer Communication with the customer is needed in almost all phases of Extreme Programming. During the planning process.

CHAPTER 4. 25 Figure 4.2: Extreme Programming planning/feedback loops [6] . So remember: do not work more than one consecutive week of overtime. EXTREME PROGRAMMING enough.

while data are stored in the relational database.26 CHAPTER 5. it is not possible to access only the desired object. However. there are a number of alternatives that can be utilized during the application implementation. 5. • Serialization . The persistence layer manages loading/saving of objects based on predefined SQL queries. However. The first solutions were evolved in the early nineties. • The application is independent of any particular database. specialized frameworks and tools are developed to allow mapping of objects to relational databases. These frameworks are commonly known as Object Relational Mapping (ORM) frameworks.The objects can contain other objects or other primitive attributes in Java language. it has to define the mapping between objects. • The granularity problem . For this reason.It seems to be a logic alternative. a high percentage of application development time is spent writing code that controls the persistence of data. a lot of differences exist in the object-oriented and relational programming. • High productivity during development of persistence layer. in my opinion. there is not any widely used implementation. this type of database has still not overcome some of the basic problems. therefore the whole hierarchy must be retrived/saved every time. the table can only consist of columns in the relational database. These are the most used ones: • SQL and JDBC . OBJECT RELATIONAL MAPPING 5 Object Relational Mapping At the present. The issues arise from the differences between object and relational paradigm. Besides the ORM frameworks. According to various studies.1 Object vs. • The source code does not contain any SQL queries. Although ORM frameworks are not the only way of data persistence. and. On the other hand. however. . The use of ORM frameworks in an application can be characterized as follows: • The data are saved in the relational database.By using this approach we create the persistence layer on our own. they are the most suitable solution for as much as 95 % of database applications. The association between the objects is achieved by the primary and foreign keys stored in the database.Java allows serialization of the hierarchy of objects into the byte-stream that can be subsequently saved into file or database. • EJB entity beans .It is probably the only serious concurrent to ORM. Since the hierarchy is stored as one unit. The idea is to have one table represented by one class and the instances of this class are denoted by table records. good manageability and performance of persistence layer. • Object Oriented Database . most applications are driven by the Object Oriented approach. that’s why. it’s important to know the issues that every persistence mechanism has to address. The only argument against their use is the need to learn this new technology. relational paradigm To be able to understand the principles of ORM tools.

however. • The identity problem . <?xml version="1.connection. This problem is commonly known as ”N+1 select problem”. OBJECT RELATIONAL MAPPING 27 • The subtype problem . • Association problem . MySQL. we access data by traversing the object model (by calling the methods of objects in chronological order e. 5.0.url"> jdbc:mysql://dbhost/db </property> <property name="hibernate.jdbc.password">test</property> <property name="hibernate.g.getDistricts().In object model. The second one is based on the result of ’equals()’ method.2.g. Hibernate is considered to be one of the dominant ORM frameworks in Java platform. In the relational database.1 Configuration The Hibernate might be configured in several ways.2 Hibernate At the moment.dialect"> org. state. Oracle.Driver </property> <property name="hibernate.dtd"> <hibernate-configuration> <session-factory> <property name="hibernate.2 which I use in my application as well.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.Java supports the creation of object hierarchies (inheritance). • Object graph navigation problem . Unfortunately.getCity()). the preferred way is by the use of hibernate.cfg.MySQLDialect </property> . the direction of association has no meaning in relational database (it is always two-directional) and the associations are expressed by foreign keys.mysql.CHAPTER 5.connection.net/hibernate-configuration-2.connection.The association in object model is one-directional and is expressed by reference (one object references other one).xml file. the record is represented by the primary key value.hibernate. It supports more than 20 relational databases (e. Since it is not possible to create a hierarchy of tables in the relation database. The actual stable version is Hibernate 3.There are two ways of dealing with identity in Java. It is an open-source framework based on Java language.driver_class"> com.dialect. 5. this is not a very effective when the relational database is used since it requires one select query for each node of the graph.username">test</property> <property name="hibernate. The first one is represented by symbol ”==” that holds when the compared objects occupy the same location in memory. however.sourceforge. the type of ’many-to-many’ relation between objects must be presented in the form of binding table in relational database. we cannot use the polymorphic queries. MS SQL Server) and provides its own implementation of query language called Hibernate Query Language (HQL) to access the database data.connection. Furthermore. However.

we defined the database type (in this case MySQL). and the metadata are written directly into the source code. The options of the configuration file are far wider (see [1] for more detailed description).cfg.hbm.model. } public Group getGroup() { return group. public String getName() { return name.28 CHAPTER 5.xml . There are 3 different ways available in Hibernate to accomplish this.auction.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate. OBJECT RELATIONAL MAPPING <mapping resource="MyBusinessObject. /** .hibernate. In this case. private Group group. the user name and password. 5. Let’s look at following simple business object User: public class User { private String name. as well as the list of defined mapping files.hbm.Group" not-null="true"/> </class> </hibernate-mapping> The second method is by using XDoclet annotations.sourceforge.dtd"> <hibernate-mapping> <class name="org. The configuration files used by my applications can be found in either reporter-hibernate. the URL address of the database server.2 Mapping The definition of mapping between objects is the crucial part of the configuration of ORM framework.application.cfg.xml file.0.Category"> <property name="name" type="string"/> <many-to-one name="group" class="cz. The first method is by using stand-alone XML file User. } } We have to signal to Hibernate that this object contains the name attribute and group attribute.net/hibernate-mapping-2. <?xml version="1.2. } public String getHello() { return "Hello " + name + "!". we don’t need any external file.xml"/> </session-factory> </hibernate-configuration> In the configuration file.xml or tracker-hibernate. the driver to database.

however. } } 29 The third method is by using the Java 5. } @transient public String getHello() { return "Hello " + name + "!". } public String getHello() { return "Hello " + name + "!". the XML files have to be regenerated after each annotation modification.many-to-one */ public Group getGroup() { return group. Here is an example: @entity public class User { private String name. The second method eliminates these disadvantages. OBJECT RELATIONAL MAPPING * @hibernate.CHAPTER 5. all three methods are quite similar. /** * @hibernate.property */ public String getName() { return name. . private Group group. public String getName() { return name.class */ public class User { private String name. } @many-to-one public Group getGroup() { return group. private Group group.0 annotations. } /** * @hibernate. } } As you can see. The disadvantage of the first method is that the information about mapping and source code is placed in two different places. If one of the files is modified. so should the second one be modified too. It is handled in a similar fashion to the previously described method.

sw. close() or clear() is used. it is likely that the collision of version will be detected.attendance. it is saying that the table in the database should not be created for the existing class. The Figure 5. It means. @One-on-one . . After the objects are saved or retrieved from the database. It means that the existing class is persistent (it is possible to save it in the database).1 illustrates the lifecycle of these objects.defines association of type n-to-one between the classes.located above class body. @Many-on-one . they are not present in the database.if we delete the database representation of previously loaded object.bo and cz.0. @One-on-many .3 Objects manipulation We already know how to configure Hibernate framework and how to define the mapping between objects. By using this approach. It is important to realize the difference between object reference in memory and its representation in the database .located above the class body.defines attribute which casts as primary key.defines association of type n-to-m between the classes.reporter. The following list shows the annotations used in Java 5.defines attribute which has the role of object version (timestamp).defines attribute which shall not be saved into the database. @Id . we get the objects in Persistent state.2. @Many-on-many . @MappedSuperclass .sw. all of the attributes are implicitly considered to be persistent (designated to be saved into database). Hibernate is unable to keep this object synchronized with its representation in database.bo. The annotations of business objects can be found directly in source codes of business objects (in cz. the object will be deleted by the garbage collector.impl packages) Most of the annotations are written above the get method of given attribute.defines association of type one-to-n between the classes. we move it into Transient state. the reference of the object in the memory is synchronized with its database representation. Although it does not exist in the database. After the object has been loaded from the database and one of the operations evict(). This is also the case of my application. It is usually used together with another annotation @GeneratedValue which says that value will be generated by Hibernate. The important parameter of this annotation (as well as of the rest of association annotations) is cascade. @Entity .defines the association of type one-to-one between the classes. In this state. 5. the newlycreated objects are in the Transient state.30 CHAPTER 5.core. OBJECT RELATIONAL MAPPING The third method introduces the most matured solution. we are still referencing it in the memory. We call this state the Detached state and if we want to save the object in this state back into the database. as long as we don’t use the Transient annotation. @Transient . @Version . It eliminates disadvantages of both of the previous methods. which defines the cross-behaving of classes during saving and deleting. Let’s now clarify how Hibernate manipulates the objects within the framework. As we can see on the diagram. Once there is no reference present in the memory.core. It is usually used in the abstract classes.

OBJECT RELATIONAL MAPPING 31 Figure 5. 5.beginTransaction(). SessionFactory factory = new Configuration().buildSessionFactory(). In the next two lines down. Session session = factory. we can create new user object and save it into the database (line 6). create the object factory of the SessionFactory class based on hibernate.hibernate. session.openSession().commit(). thus no object modifications (line 9) affect its database representation anymore.class). 3. List<User> allMarians = session. 6.beginTransaction().Transaction. 5.CHAPTER 5. we commit the transaction and close the session.setName("Marian"). 4. tx. Transaction tx = session. SessionFactory factory = new Configuration(). 1. the object comes from the Transient into Persistent state. This way.xml configuration file.openSession().createCriteria(User.get(User.1: Hibernate object life-cycle [1] The basic interface designed to manipulate objects in Hibernate is org. Transaction tx = session. the session and transaction are created respectively. 7.close(). 4. 6.class.cfg. user. which serves as the transaction coordinator. Session session = factory. List<User> adultUsers = session. 3.saveOrUpdate(user).setName("Petra"). 2. session. 2.createQuery( "from user where user. user.list(). After the transaction has been successfully established.hibernate. 9.add( . 8. Let’s now look at a simple example demonstrating the use of these interfaces. In the first line we. Another important interface. Finally. Here is an example of retrieving data form database: 1.Session and it provides such methods as get() and save().age > 18"). User user = new User(). is org. User user = (User) session. 1).buildSessionFactory().

2.isSingle(true).dao packages.core.setAge(25). 8. 3. List<User> allSingle25s = session. In the development of my applications. the objects of the User class with identifier equals to 1 are loaded. By using HQL query .in line 6. By using criteria query . we define the sample object and in line 10. 9. 1.commit(). 10. I mostly use the third method and occasionally the fourth method.createCriteria(User. we create the query and pass the created sample object into it. the objects of type User with attribute age higher than 18 are loaded.close().32 CHAPTER 5. 11. Hibernate gives us the corresponding objects.sw.create(exampleUser))). The example demonstrates the use of the 4 basic methods of retrieving objects from database.attendance.in lines 7 to 9.list(). tx.list(). 12. The source codes regarding Hibernate are located in the cz. . we have to instantiate a new session prior to all actions as well as close the session at the end. By using the class and identifier . exampleUser. Similar to the previous example. "Marian")).sw.at the line 4.core. User exampleUser = new User().like("name". After we have set the requested parameters into it.add( Example. Hibernate returns us the objects whose attributes correspond to those defined in example object. we create a query by using the Criteria type. exampleUser.class).in line 18. For a more detailed description of Hibernate framework see [1].reported.dao and cz. 7. OBJECT RELATIONAL MAPPING Expression. session. By using example object . 4.

In some cases. • Since different areas of concerns are intertwined. and sometimes on application extensibility since more activity is required to be propagated down through the layers and that’s why somebody can prefer the relaxed layer architecture. it lowers the benefits of this architecture. (For example. The automated testing becomes also very difficult. thus cannot be reused or replaced with another implementation. It’s usually common practice to put all the classes related to a certain layer in a separate package. even the small changes to the UI can require changes in the database access code or other elements). LAYERED ARCHITECTURE 33 6 Layered architecture In the object-oriented applications. it encapsulates the UI components together with logic for retrieving data from database). since all the application functionality is mixed together. • The application logic is tangled with the UI logic and that makes it unable to use with different UI implementation. The separation also helps with deployment in a distributed system. that means the higher layer uses the functionality of other elements in the same layer or underlying layers but never in reverse order1 (for example the UI layer use the services of the lower layers). Separating the domain from the infrastructure and user interface layers allows a much cleaner design of each layer. Let’s look at some of the major drawbacks of this approach. such a code becomes difficult to understand. Isolated. a layer is allowed to call services upon several underlying layers. this approach can have an impact on application performance. • Similarly. however. by allowing different layers to flexibly be placed in different servers or clients.g.CHAPTER 6. the object often encapsulates all of the required functionality on its own (for example. the given layer can only access the layer located directly beneath it. • Superficial changes in source code are spread through the whole code since all the parts of the system are tightly coupled together (e. the UI layer may call the methods of application logic layer as well as the methods of service layer such as logging etc. Although this is the easiest way to write working application in a relatively short time. The layer stands for the group of classes that work together on some major aspects of the system. for example. since they tend to evolve at different rates and respond to different needs. All of these shortcomings can be avoided by following the layered architecture pattern during the application design [2].) This eliminates overhead resulting from strict layering. In this case. The scope of the objects in a layer should be restricted only to this layer and cannot 1 It’s also possible for the lower layer to communicate with the higher one. In the case of strict layered architecture. The layered architecture objective is to separate different concerns and thus allows keeping different parts of the system in isolation. in order to minimize communication overhead and improve performance [7]. they will be much less expensive to maintain. by using the Observer pattern . it is very difficult to assign clearly defined tasks to the developers. general services are tightly coupled with application logic. Layers are organized in a ’top-down fashion’. and to extend.

34 CHAPTER 6.sw.attendance.1 shows the layered architecture that has been used during the implementation of Attendance Tracker and Attendance Reporter. Figure 6.1: Layered architecture 6.ui and cz.this is the task for the application layer). access to layer’s functionality should only be provided through interface. This layer is mostly interpreted by controllers in the case of Attendance Tracker and Reporter.2 Application layer The purpose of the application layer is to implement all the logic needed by the UI layer. the objects in the UI layer should only care for UI related tasks. UI layer should only depend on the application layer and the business layer. which are an essential part of almost every Eclipse RCP application (see detailed overview in chapter 3).2 ). In order to maximize layer independency. and should not contain any additional logic .g. Figure 6. LAYERED ARCHITECTURE interfere with objects in other layers (e. which provides all the needed logic for them (for example. 6. This pattern has also been integrated into the JFace framework (see section 3. such as creating widgets and capturing mouse events. UserAdministrationDialog uses UserAdministrationController). The implementations of UI classes used by my applications are located in cz.reporter. The idea of this pattern is to split the model (business objects). Most of the layered architectures come from the Model-View-Controller pattern that is used over a wide range of systems.1 User Interface layer The user interface (UI) layer is seated at the top of layered architecture and its responsibility is to display information to the user as well as to interpret user commands. . Most of the complex UI classes instantiate its controller. The UI layer of my application is implemented through the use of the SWT/JFace libraries.sw. the view (UI layer) and the controller (application layer) into independent parts.ui packages.

The goal of this layer is to create a model of objects with names and functions similar to the real-world domain and assign the required logic to them. 6. A typical example is the User business object: public class User extends BaseBo { private String firstName = "". The way to achieve this is to imagine that there are no controllers (application layer) in the system and asking yourself the question whether I still can perform the requested business operation by using only the business objects. .lastName = lastName.g.bo and cz. there are customers and accounts.3 Service layer The service layer consists of general purpose objects that provide the various services (e. the logging service or database service) to the above layers.CHAPTER 6. model layer) is possibly the most challenging part of the system to implement. My applications use the business objects located in the cz. So we create a Customer and Account class. All of the service methods should be stateless. public String getFirstName() { return firstName.firstName = firstName. LAYERED ARCHITECTURE 35 It is also important not to implement the business logic in controllers. The service layer should be only dependent on the persistence and business layers. and give them the needed business logic. For example. The consistent fashion of the services allows the system to be easily extended without any heavy modifications. Between the calls of the service’s methods. private String lastName = "".. 6.sw.. } public void setFirstName(String firstName) { this. the information should be stored in the objects of the business layer. . } public String getLastName() { return lastName. Because of the service layer independence. } public void setLastName(String lastName) { this.attendance. in the real world. The objects of this model are usually known as the business objects and the attached logic as the business logic. The business logic implements all the necessary functions related to the given business object with the independence of this layer in mind. The business layer should be independent of the rest of layers.4 The Business Layer The business layer (domain layer.reporter packages. the service implemented in a proper way should be reused across various systems with only minor modifications. it means that the state of the object does not change by calling its methods.attendance.sw.

} 6. } . The objects contained in the persistence layer are commonly known as Data Access Objects (DAO) and they usually implement the so called CRUD (CReate-Update-Delete) business objects’ operations.5 Persistence layer The Persistence layer is responsible for the loading and the saving of the objects from the business layer. The persistence layer should only depend on the business layer. Since I’m using the Hibernate framework..36 } CHAPTER 6. I created the HibernateDAO class that implements IDao interface. . LAYERED ARCHITECTURE public String getFullName() { return firstName + " " + lastName..

it becomes one of the most used database systems in segment of small and middle sized projects. All of them are either under free or open-source license.2 has already integrated support for Junit 4.eclipse. Besides. .2 that is one of the most popular IDE (together with NetBeans and JBuilder). Testing is one of the base pillars of agile software development and it increases quality and stability of developed applications. and easy to use. 7. fast. As base platform.2 data persistence engine. Fast Track 1.com . As the main Integrated Development Environment (IDE. AJDT AspectJ Development Tools .8. It was created by Kent Beck and Erick Gamma and its main aim is to make the testing of applications easier. Other used tools and technologies include: JUnit 3. SWT libraries.2.mysql. Eclipse SDK 3. MySQL is small. JUnit includes variety of tools to work with junit tests. and BIRT design and report engine for report designing and processing.org . I used the Java version 6.03 This plugins enables Eclipse to connect to Subversion repositories (subversion is open source revision control system).provides tools that enable us to use AspectJ in a more comfortable way. I will briefly describe the tools and technologies that were used during the development process.2. Owing to its license type and its speed. I’m using Eclipse RCP as the base platform of my application.1 JUnit is indubitably the most used testing framework for the Java programming language nowadays. I extended the Eclipse functionality by installing the following plugins: Subversive 1. MySQL MySQL is relational database management system (RDBMS) that is based on declarative programming language SQL (Structured Query Language). Hibernate 3.CHAPTER 7. progress evaluation and issue tracking. This chapter focuses on the process of application design and implementation by using the principles of Extreme Programming. MySQL is free to use and it is freely downloadable from www.org .0 Plugin supporting the agile development process. APPLICATION REALIZATION 37 7 Application realization The essential part of my diploma thesis is the Application. I used the Eclipse RCP framework.junit. Fast Track’s goals are to keep records of working tasks. It’s open source and you can freely download it from www.2. from technologies previously described. Eclipse can be freely downloaded from www. I used Eclipse SDK 3.1 Used tools and technologies First of all.0 and. AspectJ Aspect Oriented Software Development extension for java language.

Sybase PowerDesigner 12.tigris. if properly applied. It helps developers to effectively implement the enterprise architecture and brings analysis and design techniques to you application development. UML modeling tool that includes support for all standard UML 1.com .1: Phases of Extreme Programming 7. Figure 7. I will follow the steps depicted in Figure 7. Some good examples of such applications are MySQL Administrator or MySQL Query Browser that are freely available at MySQL home page www. ArgoUML is freely available at argouml. APPLICATION REALIZATION It is possible to communicate with the database engine directly through command prompt.org .mysql. 7.4 diagrams.1 during the development process. However. easy to use.1 Trial PowerDesigner is sophisticated modeling and design tool. the Extreme Programming methodology recommends to follow certain set of rules that.38 CHAPTER 7.3 Exploration The exploration phase focuses on activities that help you better understand the customer’s needs and how the whole application will be designed and built. will lead into the successful product. It is written entirely in Java and I used it for modeling of class diagrams. it is a good practice to use one of either commercial or free GUI tools that make your work with database more comfortable. Business Process Modeling and market-leading data modeling. According to this methodology. PowerDesigner provides several standard data modeling techniques like UML. . ArgoUML ArgoUML is open source.2 Getting started As we already learnet in chapter 4. I used it to design the rest of diagrams in this chapter.

As long as we follow the concept of extreme programming. During the release planning process. Well. Table 7. what the main goals of the application are.1: User stories (1/2) Priority 1 Estimate 2 Browse work records Modify/Delete work records Employee login and logout Create parameterized report Report preview 1 1 1 2 3 3 0. That means the time when he started. Tracker should log employee automatically in and also should be able to record the activities the employee has been working on. System must offer a way to enable the employee to log in and log out. we need the customer to propose his vision of the system.e. APPLICATION REALIZATION 39 At first.1 and 7. let’s now construct our metaphor: Imagine the system as the book where everybody signs in at arrival into the office and also sign out when leaving. The goal of metaphor is to clarify the system to everyone in simple form. when he has done the work and the activity he was working on. It supposed to by informal and easy to understand description of the system architecture. in the form of rich reports. The vision should consist of no more than a few sentences. User is able to create parameterized statistical report related to employee’s attendance. we will focus on constructing user stories based on the customer’s vision of the system. The manager can take the book at any time and look into it to check the attendance of the employees. Each user story should consist from one to three sentences. The proposed vision for my application is as follows: The desktop application that is designed for tracking of employees attendance with the reporting capabilities that enable authorized user to see the outcome of the tracker in a human readable format. In other words. i. User is able to preview the defined report. but also within the team of developers itself. Each row also contains the priority and initial estimate to complete. It also helps us to name the parts that would be hard to imagine otherwise. Tables 7. Employee can browse through all his records. Everybody also needs to specify a note about what he/she was working on this day. 7.2 show the user stories that have been defined by the customer.1 User stories In the next phase.5 8 1 .3. Story name Add work record Description Employee should be able to insert a record about his work. The importance of the metaphor lies mainly in the communication between the customer and the developer team.CHAPTER 7. stories are not only used as templates to be included in the release but also as templates for acceptance tests. Employee should be able to modify or delete the selected record.5 1. what are the goals of the application that have to be met. we need to construct the metaphor of the system based on preceding vision.

we ask the customer to split the following stories into more accurate ones.2: User stories (2/2) Priority 3 4 4 4 4 4 5 Estimate 4 1 1 2 0. The system should allow the addition of new parameterized reports in an easy manner. The system should allow the exporting of the report into HTML format. modify and delete user and its rights.40 Story name Predefined report templates Delete/modify report Save report User administration Export to PDF format Export to HTML format Tray icon notification CHAPTER 7.1 and 7. The employee will be notified about his actual activity state by the icon in the tray panel and the icon also provides context menu with all the needed actions to handle the application in a comfortable way. These estimates are just initial estimates and the more accurate values will be calculated at the beginning of the iteration when the user stories are processed. the priority reflects the business value of the story. These stories have no evident outcome that can be seen by the customer but they represent the essential part of the application and cannot be avoided. 1 Priority 1 3 Estimate 1 2 Man-day equals to the work one person can produce in a day . Table 7. It may be possible to store the created statistical reports in a central location.5 0. The system should allow the exporting of the report into PDF format. The employee can browse through records of the selected month and year. The system should validate the data inserted by user and announce if validation failed. The estimates provided by tables 7.5 2 Data validation and verification Report extensionality 5 5 1 2 User stories are sorted in the same priority in which they will be developed. Authorized person can add. some of them are difficult to assess. Priority 1 represents the story with the highest priority. We will create so called technical stories which are created by developers mostly to realize the application infrastructure (that is also our case). however. therefore. APPLICATION REALIZATION Description There is a set of predefined report templates available to user. Table 7. User can modify or delete already created reports. We have completed the user stories. Most likely. The story ’Browse work records’ can be further specified as follows: Story name Browse daily work records Browse monthly work records Description The employee can browse through his daily records.2 are given in ideal man-days1 .3: ’Browse work records’ stories The story ’Create parameterized report’ is very uncertain and there is a lot of work covered by this story.

5: ’Predefined reports’ stories By looking at list of user stories it is evident that the stories can be divided into two distinct categories. For the moment. Zero Feature Iteration (ZFI) has a broader scope than the ZFS. Priority 2 2 2 3 Estimate 1 2 3 2 Table 7. In this case the whole iteration is set to address project’s architecture and infrastructure.6: Stories separation .6 shows how the stories will be redistributed between applications. The first category concerns the tracking of the employee’s attendance records and the second category. two reports will be designed. Therefore. Solving the architectural issues early is significantly easier than addressing them during later release stages.4 Story name Report domain model Explore BIRT engine Report infrastructure Create report Description Design report domain model. Attendance Tracker Add work record Browse daily records Browse monthly records Modify/Delete records Employee login and logout Tray icon notification Data validation and verification Attendance Reporter Report preview Parameterized reports Predefined reports Report extensionality Save report User administration Export to PDF format Export to HTML format Data validation and verification Priority 3 4 Estimate 2 2 Table 7. Table 7. refers to the reporting of related tasks. The user can create new report based on predefined template. Leaving core architectural parts to later release stages can significantly increase project risks by means of time.CHAPTER 7. The table 7. we will separate the whole functionality into two distinct applications: Attendance Tracker and Attendance Reporter. Explore capabilities of the BIRT report engine and BIRT design engine. Report template related to summary statistics of group of employees. quality and cost.4: ’Create parametrized report’ stories The story ’Predefined reports’ also needs to be specified in more detail. I used the ZFI for realization of the user stories defined in the table 7. Essentially. Design report infrastructure. APPLICATION REALIZATION 41 Some XP theorist suggests creating one more user story called Zero Feature Story (ZFS). ZFS is the story that is dealing with the integration of used technologies and the setting up of the development environment. Story name Individual report template Summary report template Description Report template related to individual employee statistics.

In such a way.42 CHAPTER 7. we re-evaluate the user stories estimates and priorities according to the actual progress and customer requests. we can come up with an initial release plan. it will always take you more than one day. the business value is being delivered on the project. More specifically the user stories with priority 1: • add work record • modify/delete work records • browse daily work records • employee login and logout The customer wants to have the usable product as soon as possible. the customer may expect the first release to be done in about 10 working weeks. Reporter has a wide technical . APPLICATION REALIZATION At the end of the exploratory phase. 2. at which. thus I set my load factor to 2 at the beginning. a 3 is typical and a 4 and higher is used when the programmer is experiencing new technology. the release should be done in approximately 2 * 25 = 50 working days. the project velocity is a measure of the rate. The customer wants me to cover user stories referring to Attendance Tracker by the first iteration. the customer and developers get together for an iteration meeting. if you could totally concentrate on it without interruption and with a full understanding of the used technology. imagine yourself to get this task done in the real world. The number of days it actually takes is the load factor. We can say that the load factors from 2 to 5 can be considered as normal.4 Release planning Based on the user stories we defined in the previous section. According to the rules of Extreme Programming. Prior to each iteration. As I’m the only programmer working on the project. It’s important to realize the difference between ideal and real man-day. it is the numbers of ideal man-days that I can deliver during iteration. thus the total estimates of this release is 25 ideal mandays. The specification of the system will be further refined during the iteration planning and development phase. 7. As long as you are not an ideal programmer. we need to determine the project velocity. Now. the system metaphor as well as the user stories. The customer is allowed to add new user stories and change the release plan any time he finds it needed. Generally. Basically. a load factor 2 is optimistic. Each iteration should range between 1 to 3 weeks that must be considered during the planning. Let’s say I have a good understanding of the business requirements and the technologies. that’s why he gives preference to Tracker application before Reporter application.1 1st iteration Planning phase We have the release planning successfully done and it’s now time to select user stories for the first iteration. 7. we will have defined the vision of the system. The customer wants the first release to include stories with priorities 1.5. Think of a task that would take you whole day. In our case. where the customer picks the user stories that are going to be implemented in the forthcoming iteration. At the end of each it iteration. The customer and the development team have now a basic idea of what the product requirements are and the needed technologies.5 7. 3 and 4.

APPLICATION REALIZATION 43 background that must be overcome prior to any UI programming thus delivering the usable product. The record must remain deleted after the application restarts. Work record removal Employee selects existing work record from work record list and presses button ’Delete’. The record must be deleted from the list. 7.CHAPTER 7. Start up Attendance Tracker. As long as my load factor is 2. Authorization must fail and employee is not permitted to work with application. The total time of selected user stories is 5 ideal man-days. fill in username ’test’ and password ’test123’ and the employee must be allowed to work with application. 4. the corresponding user story can be considered to be done. The task can be used to more precisely estimate the total development time needed for the given user story and successively for the estimation of the next iteration. Next. the login dialog appears. 3.2). The record must be in the list after the application is restarted. end time 17:30. the total time of first iteration will be 5 * 2 = 10 calendar days (2 working weeks). user name ’test’ and password ’test123’. The customer’s responsibility is to provide the specification of the acceptance tests for the users stories defined for the first iteration (see section 4. This method is really rapid and provides good enough results (among other methods such as HTML or Flash . Insertion of work record The employee fills in the work record form with start time 9:00. end time: 17:30 in the record. Work record modification The employee makes modification of the existing work record in the record list. These are the acceptance tests in my case: 1. The modified record must be in the list after the application is restarted. 2. Subsequently. After successful login. The only active button now is the ’Login’ button and after it is pressed.5. After successful completion of each of the preceding tests.5. the employee presses the ’Log out’ button and will be logged out of the application. I used the paper prototyping to get the basic idea about UI composition. Employee must be asked for user name and password. The work record must show up in the work record list with given total time 8 hours and 30 minutes. The prototyping should not be underestimated because it can save time and money since it enables developers to test their product before any line of code is written.2 Development phase Now we have a pretty good idea of the features that will be implemented and we can rapidly mock up some prototype screens to show the customer how the application will look like and confront his ideas. The other thing is that Tracker fills the database with valuable data that will be processed by the Reporter later on. I will break down the user stories into individual development tasks that are required to implement each of the stories. selects the ’Office work’ activity and press the ’Add’ button. Fill in username ’test’ and password ’123test’.2. He replaces old values with values: start time: 10:45. Employee login and logout Create user with name ’Test user’. The record’s total time value must be 6 hours 45 minutes. In this case it will take much longer.

The role is represented by the enumeration UserGroup which contains information about a given group.2: Attendance Tracker prototype It’s a good practice to use pieces of paper for a design composition as well as different colors corresponding to different UI components (e. After we are done with a prototype. The BaseBO class is an abstract class that is the ancestor of all persistent objects used in application. buttons. It includes the names of all business objects.3 shows the class diagram of the required business objects. lists). The User class contains information about the employee and the set of his roles.g. we came with the following prototype: Figure 7. Instead of spending hours to get layout to position a column in the right place. their attributes and relations but no methods (we don’t need them right now). The prototyping stage is the right time to discuss design issues and the flexibility and disposability of paper enable us to experiment and develop UI as fast as possible. we will create a simplified class diagram. The Figure 7. After some time spent with customer discussing the UI design of Attendance Tracker. end time and the realized activity. APPLICATION REALIZATION prototyping). If you don’t like ideas that don’t work. The TimeRecord contains information about realized work. The class Activity is an enumeration that denotes an activity realized by the user.44 CHAPTER 7. It comprises the user id. throw them away and move on. you can draw a prototype and experiment. editors. start time. .

The database service is denoted by the DatabasService singleton class and its mission is to supply the database functionality to the rest of the application. Next. Mapping tells Hibernate how to map business objects in relation to database model.bo. In so far as we are using Eclipse IDE. Its core functions are to serve methods for loading and saving persistent objects from/to database. since the only methods are the get/set methods to attributes2 . we install applications such as MySQL server and there is nothing to prevent us from setting up the project and configuring all the needed frameworks such as Hibernate and BIRT. The only requirement the persistence layer must met is to implement provided Data Access Object (DAO) interface. For other objects to be able to access this layer. We implement classes of the business objects. it wouldn’t be possible to save them into the database. . The database Service is independent on the underlying persistence layer. they have to confront the database service. APPLICATION REALIZATION 45 Now we have collected all the information needed to start the programming process.core. Its responsibility is to retrieve and save any of the business objects from/into database. DAO encapsulates all access to the underlying data source.attendance.3: Attendance Tracker business objects We start with implementation of the business layer (see chapter 6).sw. Afterwards. thus easy to test and extend. we focus on the persistence layer. we define the mapping of business objects for the Hibernate framework. Further. It manages the connection with the data source to obtain and store data. we have to install all the required plugins prior to all actions. thus all meta-information are inserted directly into source codes of the business objects. In my case. since this layer is independent on other layers. It’s not required to implement tests for them.CHAPTER 7. The created business objects are located in package cz. or automatic overwrite of equals() and hashcode() methods. Figure 7. I used the annotations as the primary mapping technique. otherwise. the DAO for Hibernate framework will 2 Eclipse provides a number of useful tools that enable rapid development such as automatic get/set method generation based on attribute names.

there is nothing to prevent us from starting to implement the selected user stories. the customer finds out that new stories should be provided by the application. For this purpose I’m using the controller classes where needed. all these things are already done and we only concentrate on adding actually wanted functionality into the system. in the first iteration we set up the development environment and integrate the needed technologies into the project. it is a good practice to separate the logic behind the UI from the UI itself.3 Evaluation phase Prior to the second iteration planning. the user stories might be re-prioritized. After the first iteration. During the realization of the ’employee login and logout’ user story. we are done. All of the UI classes reside in cz. For example. there is nothing to prevent us from delivering the software to the customer for further testing. We remove the defects found by the customer. After all of the tests have been successfully passed. Possibly. we now have more accurate information about the application progress and that’s why new and current stories should be re-estimated.dao package.sw. • Addition of user stories. It is caused by the higher load factor. the following actions should be considered: • Defects removal. The higher development time cost was mostly caused by the overestimating my knowledge about the used technologies. Since all the stories have projection to the user interface. Prior to any implementation. This approach makes testing of UI logic much easier.attendance. we specify. In the following iterations.core. APPLICATION REALIZATION be implemented. My HibernateDao class is located in cz. . It may happen (and happens) that during the application testing. After the persistence layer has been successfully implemented. If all of the tests are successfully passed.ui package. Based on the previous estimation changes.attendance. we have to implement the business objects and service classes and that of course consumes a lot of time. In this situation we add suggested stories into the list of project’s user stories. we define all the needed tests. • Estimation of user stories.sw. This pattern enables us to extend the functionality of the system in a simple way just by creating new DAO implementation for the required data source.sw. During the UI programming. we analyze the progress after the first iteration.5. The iteration actually took 12 real days to implement (the original estimate was 10 real days). I had to implement authentication service (located in cz. After the product has been tested by the customer. It’s important to note that the time needed for realization of the user stories in the first iteration is most likely to be higher. the new release date.46 CHAPTER 7. 7. their code will be mostly concentrated in the UI layer. I’m using the SWT/JFace (see chapter 3) framework as my primary UI toolkit. • Release reevaluation.services) that implements all of the required functionality for authentication of the user.core.attendance. Generally.

7. Similarly to Attendance Tracker. The serializer’s test class is available in cz.1 Planning phase In this iteration we will focus on the following technical stories: • report domain model • explore BIRT engine • report infrastructure The total needed time is 6 ideal man-days. They hold the reference to parameter type instance (IParameter) and the value. all of the objects are inherited from BaseBO class that is the predecessor of all persistent classes.2 Development phase Prior to other development activities we have to define the business objects of the business layer.6.sw. For that reason the total estimated time is 15 real days of work for one programmer (3 working weeks). The contained value is of the String type in order to save it into the database.sw.6 2nd iteration This iteration is the Zero Feature Iteration and its main goal is to create infrastructure of the Attendance Reporter. . The implementations also provide the list of reports (IReport) that reference given template (bidirectional association) to be easier to work with. This can be done using ParameterSerializer that can be found in cz.sw. the domain is specified using interfaces.core package and their class diagram is depicted in Figure 7.5 for this iteration. 7. Its main role is to provide the UI editor class name which is used for this parameter’s value modification. Business objects are all located in the cz. In this case it is the developer’s responsibility to define appropriate tests of the provided functionality.CHAPTER 7. The ITemplate interface stands for the template of a report. 7. there are no additional stories required by the customer and no estimates have been changed.reporter. The classes that implement the IReportParameter interface are the real parameters with real values. I raised my load factor to 2.tests package.core package.reporter. when working with values different from String. It provides the name of the design class that will be used for projection of report to UI and the set of parameter types (IParameter) belonging to this template. These parameters are specific to each IReport instance. For this reason.6. APPLICATION REALIZATION 47 In my case. This raises the model flexibility and opens it for the future extensions since the application will be independent on underlying implementations. Because of the new technology I’m going to use (BIRT framework).reporter.4 In this case. The IParameter interface is the representation of the parameter type used by templates. we have to ensure proper serialization and deserialization of given value to and from String respectively.

The BIRT’s designer first composes a XML design file that contains the information about the data source.2. Let’s now look at some drawbacks of this approach: .6. and the list of report parameters values represented by IReportParameter implementations. definition of queries. list of report parameters and of course the report design. APPLICATION REALIZATION The implementation of the IReport interface is the real report that comprises the name. let’s look briefly at how BIRT processes a report. Figure 7. its template instance (ITemplate). we will concentrate on the design and implementation of the report processing functionality.1 Design decisions First. this file is read by the BIRT’s report engine which initializes data source. Afterwards. load data from database and creates report in requested format (a more detailed description of BIRT can be found in [17]).4: Attendance Reporter business objects 7. In the next section.48 CHAPTER 7.

• Design can be only customized to such a degree that the GUI designer allows it to. The ReportParamsDialog dialog first reads the names of each editor’s classes from corresponding ITemplate parameters. Afterwards. The report object is moved to Designer Service. Designer’s responsibility is then to create BIRT’s XML report based on the report’s design (IDesign) and parameters values (IReportParameter).2) After few days of BIRT framework investigation. • Some of the design formatting can be only done during the processing phase by using corresponding element handlers. It can be expressed by the simplified conceptual schema depicted in Figure 7.1.g. and the values are subsequently stored as report parameters (IReportParameter) in the newly created report (IReport). • The queries to database can be only specified in a simple form (no compound queries are allowed). This is done by using the BIRT’s designer engine. • Design phase is strictly separated from data loading and processing phase. the number of table columns must be statically defined during the designing phase and cannot be dynamically determined after the data has been acquired).5 Figure 7. • Static nature of the design components (e.5: Report life-cycle Let me clarify the way how the report is created and processed. I designed a model that eliminates these shortcomings. Subsequently. Now on to the next stage. APPLICATION REALIZATION 49 • Report parameter can be only specified as a simple type (e.CHAPTER 7.g. • Buggy GUI designer (as of version 2. it’s not possible to use a list of users as a report parameter). the XML report is delivered to Reporter Service where it is processed by using BIRT’s reporter engine and finally the output in required format is generated (currently either . The users then fill in the editors fields. it creates a composition of these editors and opens the UI dialog.

APPLICATION REALIZATION The implementation of IDesign encapsulates all the needed functionality of the report’s design. IDesign together with IElement introduce a simple way how to dynamically design BIRT report in an easy manner. Let’s now describe the core services of the report lifecycle: Designer Service and Reporter Service.2 The Designer Service Figure 7. The implementation of these interfaces will be provided in the next iteration.6: Designer Service sequence diagram . It defines the design elements (IElement) and their layout.50 HTML or PDF format is supported). 7.2.6. CHAPTER 7.

designer. date etc.g. the designer creates the BIRT’s designer session and BIRT’s design handle. .reporter. it is serialized into XML stream and passed to the Reporter Service for further processing. Each data set is bind with data set handler class (cz. It also assigns simple values to some of the elements (e. which ensures the requested data to be fetched to design components during the processing phase.DataSethandler).6). When the design is done.7: Reporter Service sequence diagram After the initial phase is over.CHAPTER 7. user name.sw. The followings steps are: Designer first creates the data source and all of the data sets.handlers. APPLICATION REALIZATION 51 Designer’s Service responsibility is to create BIRT’s design file based on the Reporter’s IDesign implementation (see Figure 7. Designer walks through all the contained elements (IElement) and creates corresponding items in BIRT’s design. First of all. Figure 7. can be rendered in this phase).

but the estimation and prioritization of some stories have changed. 5.reporter. the iteration actually took 3 more days. 3. The report shows the data related to selected employee. In comparison to the estimated value of 15 real working days. the first release should by available in 14 * 2 = 28 real mandays (more than 5 weeks). Creates BIRT report engine’s render task by utilizing design XML stream. I set my load factor back to 2. After the first access to the service. There is still 14 ideal days remaining to the end of 4th iteration. Initiates render context of the BIRT report engine (currently either HTML or PDF format is supported). the engine is properly disposed. Therefore. It may be split into the following steps: 1. Uses BIRT designer to generate XML stream based on previously created design. Figure 7.7: Changed user stories after 2nd iteration The original values are in parenthesis.6. The customer didn’t provide any new user stories.52 CHAPTER 7. 7.designer’ package.7 shows the sequence diagram of the report generation process. I assume I will be able to proceed faster with the next iterations. Runs the task and returns stream in the corresponding format 7.3 Evaluation phase It’s now time to evaluate all the work we have done so far.7 3rd iteration The third iteration’s goal is to provide user interface to Attendance Reporter’s infrastructure created in the previous iteration.2. In so far the core functionality is already implemented. Story name Browse monthly work records Individual report template Summary report template Description The employee can browse through records of the selected month and year. 7. It was caused the increased difficulty of the infrastructure design and implementation. .6. 4.sw. Dynamically creates Design instance based on given report’s (IReport) design class. The report shows the summary data for the group of employees. For that reason. APPLICATION REALIZATION Designer Service is implemented by the DesignerService singleton class and it resides in ’cz. 2. Priority 4 (3) 3 3 (4) Estimate 2 3 (2) 2 Table 7. the BIRT report engine is initialized and after application exit.3 The Reporter Service The reporter Service is represented by the ReporterService singleton class.

7. 7. The editor’s area is the place where the report will be drawn.1 Planning phase 53 We will be implementing the following user stories: • create report • report preview • individual report template • summary report template According to the tables 7.7). Similar to the implementation of Attendance Tracker.1. The viewer is made up of Tree component with predefined templates and the user customized reports. as in the case of Tracker application. we can start to work at the 3rd iteration. Since Reporter must be able to access Tracker’s business objects in order to process recorded data.5 and the previous changes to the user stories (table 7.7.2 Development phase Similarly. we mock up paper prototype to get the basic idea about UI. After the customer provides all the acceptance tests. 7.CHAPTER 7.7. The final prototype is shown in Figure 7. APPLICATION REALIZATION 7.8: Attendance Reporter prototype The UI will consist of one viewer component (Report Explorer) and an editor component.4.8: Figure 7. the DAO has to provide additional methods . we implement the persistence layer with corresponding DAO implementation first. the total realization time should be 8 * 2 = 16 ideal man days.

Each of the parameter types has assigned an UI editor class.Parameters enum.9 shows the class diagram of implemented editor classes. The element that will be accessed during the processing phase through handler must overwrite the getDataSetRecords method defined by Element abstract class.templates.54 to be able to access these objects.report’s line chart representation PieChartElement .report’s pie chart representation . Figure 7.config.9: IParameterEditor implementations The other things that have to be done are the implementations of IDesign and IElement interfaces. Figure 7. These are saved into database by the first application launch.reporter. I implemented the set of following classes: HeaderElement .config package).element represents the list of pairs: name.report’s dynamic table representation LineChartElement . All of the IElement classes can be seen in the Figure 7. APPLICATION REALIZATION The application makes use of the set of predefined report templates and parameter types (they are specified by enums that resides in cz. The ReportParamsDialog ensures the message is passed an among all editors. CHAPTER 7.reporter. The specification of parameters together with assigned editor classes can be found in cz.the header of the report ParametersElement . These implementations are developed simultaneously with IEditor implementations. All the editors implement the IParameterEditor interface.10: Each of elements contains the create method that writes its UI code into BIRT’s report.sw.templates. There is also the notify method available for each of editors to notify it about the other editor’s actions.sw. value TableElement . Each of them has its parameter type assigned and provides methods to set and get the serialized value to and from the editor respectively as well as the listener registration methods to be informed when the value in the editor has changed.

I have implemented two of them: DataSetHandler and ChartHandler and they are located in the cz.10: IElement implementations The implementations of the IDesign interface are shown in Figure 7. They are called during the report processing by the BIRT report engine.11: IDesign implementations Note that each of the designs implementation has its own controller class. DataSetHandler provides .reporter. The only important thing that should be mentioned is the role of handlers.CHAPTER 7. Design class encapsulates all of the elements (IElement) that are part of the current report.sw. Figure 7.designer. it ensures the loading and processing data using the database service. In my case. According to the user stories I implemented IndividualDesign for individual report template and SummaryDesign for summary report template. APPLICATION REALIZATION 55 GridWrapperElement .handlers package.11. The controller provides all the logic required by the UI class. Handlers are the essential part of the system.grid wrapper for other elements (puts element into grid with defined label) Figure 7.

7. In this iteration the additional features will be implemented in both Attendance Tracker and Attendance Reporter. however.5 (1) 2 Table 7. Priority 4 4 4 (5) Estimate 0.3 Evaluation phase The total needed time spent in this iteration was 14 real work days (estimated value was 16 real days) thus estimates were a little overrated.8: Changed user stories after 3rd iteration 7.7 = 13.8 4th iteration The development process in the 4th iteration is pretty much the same as in the previous iterations. Story name Delete/modify report Save report Tray icon notification Description User can modify or delete already created reports. 7.g. we can now re-estimate the stories depicted in table 7.8. dataset for table) and ChartHandler mostly provides formatting data for some elements (e.56 CHAPTER 7.6 real days (almost 3 weeks) and that is the estimation of the 4th iteration as well. it’s very unlikely that he won’t be satisfied with the application ’look and feel’ or functionality.5 (1) 0. The employee will be notified about his working state by the icon in tray panel and icon also provides context menu with all the needed actions to handle the application in a comfortable way. After completion. I will be able to deliver the product in 8 * 1. This is one of the major benefits of the iteration driven development process. I can now lower my load factor to 1.7. based on the previous experience. the final applications will be delivered to the customer. APPLICATION REALIZATION all the needed data that should be drawn by the report element (e. In that way. The final applications’ look is depicted in the Appendixes B and C . Since the next iteration doesn’t require me to use any of new technologies and I’m experienced enough after the previous iterations. The customer didn’t provide any new user stories. Since the customer participated in the project. It may be possible to store the created statistical reports in a central location.g. the format of the chart series labels).

I decided to follow the principles of Extreme programming (XP) methodology. tables etc. It is capable of designing. Various methods have been evolved to overcome this issue. such as lists. I was able to ensure the high quality and reliability of the produced code. Eclipse introduced to the world of application development SWT and JFace libraries that help developers to build rich. CONCLUSION 57 8 Conclusion At the beginning of this work. I designed and implemented the Attendance Tracker application that is capable of tracking records of the employee’s activity. BIRT. such as continuous testing and refactoring. I focused on core UI elements that can be utilized by RCP application. In chapter 5. In the practical part of this work (chapter 8). concentrating on short release cycles. Since there are significant differences between object-oriented and relational approach. Chapter 3 first describes the structure of SWT’s core elements and later in the chapter. I demonstrate the use of JFace components by utilizing both the traditional as well as the MVC approach that is more suitable for systems where good scalability and maintenance are required. object-relational-mapping is probably the most suitable solution of how to achieve this in a comfortable way. XP offers to developers a set of good practices that ensure quality and high business value in the produced code. native looking. most of applications store data into relational database. By utilizing layered architecture. rich user interface that can be easily customizable by the user. the enterprise-sized applications can be built that are easy to understand and to extend. I explained the essential parts of RCP such as the OSGi framework and the platform Runtime in order to be able to implement the Eclipse RCP application and to better understand the structure of this framework. I sketched the aspects of using layered architecture pattern as a technique of splitting application logic into loosely dependent layers. I clarified the role of plugin as the core element of every RCP based application and the features which plugin brings to the system. these risks may be eliminated by using some of the time-tested methodologies. it’s up to the developer to provide the needed functionality. I designed and implemented two RCP applications by utilizing previously described techniques. The development process always brings some risks. So far as one of the goals of this work was to develop a framework that allows graphical visualization of statistical data. Chapter 4 explains the key principles of this methodology. I described Hibernate as my primary ORM framework and provided the options of its configuration. In chapter 6. offers a variety of graphical elements. In the first phase. however. The Views and Editors represent an effective way to build full-featured. charts. and responding user interfaces. while it eliminates any extra work. The significant part of the development process was devoted to the design and the implementation of the Attendance Reporter. Following the XP principles.CHAPTER 8. Nowadays. Next. I decided to utilize BIRT design and report engines. however. that can be utilized by a wide range of applications to create decent looking business reports. that is one of the Eclipse projects. continuous testing and communication with the customer. displaying and exporting .

I provided two predefined report templates that allow the creation of individual as well as summary attendance reports. . company and are still in use.o. The framework provides a set of components to build new report templates in an easy manner. This way. Report parameters are saved into the database and can be modified by the user anytime. defects must be fixed as soon as possible. If all the tests don’t run at 100%. thus they make it easy to extend the framework. Both of the realized applications have been successfully used by Simpleway s. for different departments).r. Moreover.58 CHAPTER 8. otherwise it is not possible to continue in development. CONCLUSION customizable statistical reports based on the predefined templates. it is possible to have defined reports for the different set of parameters (for example. One of the major benefits of the Extreme Programming development is that tests are an inherent part of the development process. the product is continuously tested by the customer and that’s why there is no need to have an extra testing phase.

Stal. http://www. Sommerlad. Burnette. 1996. and I. Hendrickson. [15] D. Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design. Scarpino. and D. King. http://www. 2004.the project home page. Opdyke. [7] M. 2004. [16] M. Peh. A. Ng.org/. Daum. 1st edition. Eclipse Rich Client Platform: Designing. Addison-Wesley Professional. and R. Tatchell. Addison-Wesley Professional. Manning Publications.CHAPTER 9. Pro Hibernate 3. [13] J. Bondur. Chatalbasheva. McGovern. French.extremeprogramming. 1st edition. 1st edition. BIRT: A Field Guide to Reporting. Linwood. Manning Publications. [9] D. Minter and J. 2005. Addison-Wesley Professional. S. A. Fowler. 1st edition. D.-M. [6] Extreme programming . Integrating and Extending BIRT. Eclipse in Action: A Guide for the Java Developer. Hibernate in Action. 1st edition. 2001. 2nd edition. Wrox. T. http://agilemanifesto. Gallardo. Holder. 2nd edition. Bauer and G. Professional Eclipse 3 for Java Developers. Manning Publications. 1st edition. and N. 2006. Pattern-Oriented Software Architecture: A System of Patterns. [2] F. 1st edition. P. Rubel. REFERENCES 59 9 References [1] C.org/. H. W. 2000. John Wiley and Sons Ltd. E. Lemieux. Rohnert. Anderson. [10] R. Analysis Patterns: Reusable Object Models. Hannemann. Mihalkovic. [14] D. Beck. 1st edition. 2006. McAffer and J. and R. E. Extreme Programming Installed. S. [17] J. Roberts. Addison-Wesley Professional. Meunier. 1st edition. 2005. J. [3] E. Buschmann. 2005. Prentice Hall PTR. Jeffries. J. Weathersby. 1st edition. . Eclipse: Building Commercial-Quality Plug-ins. Jeffries. [5] Equinox . Brant. and M. 2003. C. SWT/JFace in Action. K. Clayberg and D. [11] C. R. Larman. 1st edition.eclipse. 2004. 1999. [4] B.a gentle introduction. Fowler. [8] M. Apress. [12] Manifesto for agile software development. 2001. 1st edition. AddisonWesley Professional. Addison-Wesley Professional. and L. Hague. Refactoring: Improving the Design of Existing Code.org/equinox/. and Packaging Java Applications. Coding. Addison-Wesley Professional. 1996.

REFERENCES .60 CHAPTER 9.

LIST OF ABBREVIATIONS 61 A List of abbreviations BIRT Business Intelligence and Reporting Tools CRUD Create.APPENDIX A. Update and Delete CVS Concurrent Version System DAO Data Access Object HQL Hibernate Query Language JAR Java ARchive JNI Java Native Interface JRE Java Runtime Environment MVC Model-View-Controller ORM Object-Relational Mapping OSGi Open Services Gateway initiative RCP Rich Client Platform RDBMS Relational Database Management System SVN SubVersioN SWT Standard Widget Toolkit UI User Interface UML Unified Modeling Language XML eXtensible Markup Language XP Extreme Programming ZFI Zero Feature Iteration ZFS Zero Feature Story . Read.

LIST OF ABBREVIATIONS .62 APPENDIX A.

the login name to the database (login name should be the same for all users since the application uses its own user authentication management) Password .connection wizard The following parameters are needed by Tracker to be able to connect to database: Server URL . insert and select access rights to MySQL database After the first application start.1: Attendance Tracker . . host. the configuration wizard will show up (Figure B. ATTENDANCE TRACKER USER MANUAL 63 B Attendance Tracker user manual This manual will show you how to setup and use the Attendance Tracker.the port on which the database server is listening (the default value is 3306) Database .the domain name or IP address of the database server (for example. Figure B.APPENDIX B. Prerequisites: • installed JRE 1.com) Server port .the password to the database After you have filled in all the parameters.the name of the database (for example attendance) Username .5 or higher • create.1) and you will be asked to fill in the required parameters. you should test the connection by pressing ’Test Connection’ button.

ATTENDANCE TRACKER USER MANUAL After you have been successfully logged into the database.the user is currently logged off the tracker • Passive state . Figure B.the user is logged into the tracker and is working on some task It is possible to control the application either through user interface or through content menu of the icon on the tray bar. By double-clicking the try icon. the Tracker’s main window will appear. but is passive (for example. you will be asked to enter the user name and password to log into the Attendance Tracker (they both should be provided by your supervisor or administrator).2 shows the main application window. he is having a break) • Active state . Views There are two main views available to the user: • ’Today’ view . It is possible to show the records of the current day by double-clicking the corresponding row of the list.64 APPENDIX B.it is available through the ’Month’ button and it shows the list of day records of the selected year and month.2: Attendance Tracker . Figure B.the user is logged into the tracker. .it is available through ’Today’ button and it shows the activity record list of the current day • ’Month’ view .main window The Attendance Tracker is always in either of the following states: • Log off state .

APPENDIX B. Record modification: Activity record can easily be changed by direct modification of the selected values in the record list. selecting the corresponding activity and pressing the ’Add’ button. ATTENDANCE TRACKER USER MANUAL Adding new activity record: 65 Records can easily be added either by pressing ’Start/Stop’ button or by entering the time values directly into ’Start’ and ’Stop’ fields. .

66 APPENDIX B. ATTENDANCE TRACKER USER MANUAL .

you should test the connection by pressing ’Test database connection’ button.com) Server port . In the ’Database connection settings’. you need to specify the connection setting. the following parameters need to be specified: Username . the toolbar or the context menu of the tree: • Create new report .1 shows the Attendance Reporter window after you have been successfully logged in. Although the main purpose of the Reporter is to create and show reports to the end user. and the right panel is the area where the report shows up after it has been processed. select. In the ’Preferences’ dialog choose ’Connection’ in the left panel. ATTENDANCE REPORTER USER MANUAL 67 C Attendance Reporter user manual This manual will show you how to setup and use the Attendance Reporter.5 or higher • create. The left panel shows the tree structure with predefined report templates and customized reports. Prerequisites: • installed JRE 1.to delete an existing report • Show report .to create a new report based on the selected template • Edit report . In the ’User connection settings’ area fill in your username and password. Reporter’s UI actions: Reporter is divided into two panels.the name of the database (for example attendance) After you have filled in all the parameters.the port on which the database server is listening (the default value is 3306) Database .the login name to the database (all users should use the same user name since the application uses its own user authentication management) Password . Reporter offers the set of the following actions that can be accessed either through the main menu.to duplicate an existing report • Delete report .APPENDIX C.to edit an existing report • Duplicate report .the password to the database Server URL . update and delete rights to the MySQL database Reporter setup: After the first application run. it also allows a supervisor to administer users through ’User Administration Dialog’. insert. Choose ’Edit Preferences’ from the Reporter’s main menu.the domain name or IP address of the database server (for example.to process and show a selected report in the right panel . host. Figure C.

User Administration’ menu item.main window User administration: The administration dialog can be accessed through ’Administration . The use of administration dialog is pretty much intuitive.to export a report to HTML format • Export to PDF .to show the administration dialog • Add to favourites .to remove a report from the ’Favouriter Reports’ folder Figure C. . Figure C.to add a report to ’Favourite Reports’ folder • Remove from favourites .to show preferences dialog • User Administration . By using this dialog.to export a report to PDF format • Preferences .68 APPENDIX C. ATTENDANCE REPORTER USER MANUAL • Export to HTML . it is possible to define new users of both Attendance Tracker and Reporter.1: Attendance Reporter .2 shows the administration dialog.

administration dialog .2: Attendance Reporter .APPENDIX C. ATTENDANCE REPORTER USER MANUAL 69 Figure C.

70 APPENDIX C. ATTENDANCE REPORTER USER MANUAL .

6. copy the content of the devel directory from attached CD into your hard drive.Eclipse plugins directory workspace .’ from the Eclipse main menu.6 win32 .2 directory for Linux OS eclipse win32 .6 linux . you need to have create. INSTALLATION GUIDE FOR DEVELOPERS 71 D Installation guide for developers To simplify the installation and setup process. run either devel/eclipse linux/eclipse command (Linux OS) or devel/eclipse win32/eclipse.6. choose the wanted application (either Attendance Tracker or Attendance Reporter) in the left panel and press the ’Run’ button.the Eclipse 3.Java Runtime Environment 1. The devel directory has the following structure: eclipse linux . To be able to run Eclipse IDE.. for Linux OS jre1.2 directory for Windows OS jre1. insert.APPENDIX D.the Eclipse workspace (contains both Attendance Tracker and Attendance Reporter source codes) To start Eclipse IDE. for Windows OS plugins . .the Eclipse 3.exe command (Windows OS).. To build a project. I’m providing the Eclipse installation with both projects (Attendance Tracker and Attendance Reporter) already set up.Java Runtime Environment 1. select ’Run-Run. update and delete access rights to MySQL database. select. Note: To be able to connect to database. The tables will be created automatically by the Hibernate engine after the first application run.

INSTALLATION GUIDE FOR DEVELOPERS .72 APPENDIX D.

See Installation guide for developers (Appendix D) for a more detailed description. • thesis The directory contains PDF and LaTeX documentation files of this thesis. . CD CONTENTS 73 E CD contents • bin linux The directory contains both Attendance Tracker and Attendance Reporter application files for Linux OS • bin win32 The directory contains both Attendance Tracker and Attendance Reporter application files for Windows OS • devel The directory contain Eclipse 3.APPENDIX E.2 with both projects (Attendance Tracker and Attendance Reporter) already set up.

CD CONTENTS .74 APPENDIX E.