| The Hello World Applet in Java™ 1.5: A Software Time and Motion Experiment | |||
| by Van Warren MS CS, AE © 2005 | |||
Abstract Introduction During this period, my partner and I decided that it was important to protect ourselves from the winds of frequent technical change. We coined the phase, "Dual browser, dual platform." as a label for the future development strategy. The goal was to move future application development completely to the web as the end-all destination for machine independent applications. The aim was to avoid subversion by single monopolistic interests and encourage collaboration. It was influenced by the desire to embrace various cultures, especially those featuring vinyl disks or chrome wheels which run briefly backwards.As an evolving open standard, Java™ was no exception. It ran on multiple machines including, "Wintel", Macintosh™, and Sun Workstations. Java™ ran on browsers including Netscape Navigator™, Internet Explorer™ and more recently Mozilla Firefox™. The following study examines the process of creating and deploying a "Hello World" applet in Java™ version 1.5 update.3. The objective is to apply Frederick Taylor's concept of "time and motion studies" to a simple software engineering task. The open source tool NetBeans™ is used as the IDE. Because of the large memory footprint of NetBeans™ the time and motion required to bring the user's environment into compliance is included in the experiment. My hypothesis is that the fewer context switches required of the user for a given task, the greater their productivity will be. The measure of productivity is the time that it takes to prepare the system and the time it takes to produce the "Hello World" applet. Smaller elapsed times for system preparation and applet development indicate higher productivity. Definitions
and Method The following steps in building and deploying a "Hello World" applet are documented below. Your times may vary. How long it takes you depends on your background, connection speed, system and level of distraction. To repeat this experiment exactly, click on the links or images below and use a stopwatch. I used Morimoto's ten-track timer. Specific locations are listed in the "Wintel" environment, but the idea is the same for other platforms. The table of times and context switches is included at the end in the results section. So let's begin. |
|
||
System Preparation - Memory Upgrade The project was executed on a 1.7 GHz Sony Vaio laptop with 255 Mb of RAM running Windows2000 operating system. If you have less than half a Gigabyte of RAM plan to order more memory. Java™ and NetBeans™ won't work without it.
.
|
Upgrading memory required 3 hours and 6 context switches. This required: a) exiting NetBeans™
|
||
System Preparation - Download and Install Firefox™ Download and install the latest version of Firefox™. This tutorial will work without Firefox™, but it will be slower and machine dependent. |
Downloading and installing Firefox™ took 3 minutes 5 seconds and 4 context switches. This required: a) clicking on a link |
||
System Preparation - Download and Install Java™ SDK and NetBeans™ Bundle Download and install the latest Java™ and NetBeans™ bundle. Leave your existing installation alone.
|
Downloading bundle took 27 minutes 22 seconds. Installing bundle took 15 minutes 39 seconds. Total time this step: 5 context switches. This required: a) clicking on a link
|
||
System Preparation - Download and Install Java™ Runtime Environment - JRE Download and install the latest Java™ Runtime Environment
Test that Firefox™ works on example Java™ applets by clicking here. |
Downloading JRE took 3 minutes 55 seconds. Installing JRE took 3 minutes 0 seconds. Total time this step: and 3 context switches. This required: a) clicking on a link |
||
System Preparation - Firefox™ Java Compatibility If Firefox™ does not work on the test Java™ applets, get advice by clicking here. Firefox™ only likes one virtual machine at a time. Thus, there should only be one NPJPIxxxxxx.dll files in the plugins directory. If you find extra NPJPIxxxxx.dll files, quarantine them. Many people have had problems because of this.
|
Understanding what was wrong took over a day. Checking this issue once understood took 17 seconds and 3 context switches. This required: a) opening folder |
||
System Preparation - Download and Install Java™ Documentation Download and install the Java™ documentation from here.
Install the documentation in the proper directory as shown. Your installation may differ slightly. Do not unzip the file. NetBeans™ takes care of that, using the zip file as is.
|
Download of docs took 11 minutes 16 seconds. Install of docs took 38 seconds. Total time this step: 5 context switches. This required: a) clicking on a link |
||
System Preparation - Installing the Java™docs in NetBeans Java™ is well documented and that documentation can be accessed quickly if NetBeans™ knows the location of the .zip file we downloaded above. This location is specified by the menu Tools --> Java™ Platform Manager:
Note that
the mouse is pointing at the Java™doc file at the THIRD tab.
|
This step took 38 seconds and and
6 context switches This required: a) Selecting Menu Item |
||
System Preparation - Configure NetBeans Memory Usage Edit the
NetBeans™ startup configuration file and add a new line that allows
NetBeans™ more memory.
|
Configuring
NetBeans™ memory
took 46 seconds
and 3 context switches. This required: a) opening file |
||
System Preparation - Test NetBeans™ Test NetBeans™ installation by clicking the icon that appears on the desktop.
If the program starts up without incident you have succeeded. Shut it down. |
Testing
NetBeans™ took Testing NetBeans™ took 28 seconds to open on subsequent trials. 3 context switches. This required: a) opening NetBeans™ |
||
User Preparation - Take This Break - Skim Three Pages Skim
pages 18 through 20 of the NetBeans™
IDE Field Guide excerpted here. |
Reading and understanding this took 4 minutes 11
seconds and
3 context switches. This required: a) opening Field Guide |
||
Development - Warming Up Before the Big Event Now we'll
follow the steps and create a real applet.
|
|||
Development - Open NetBeans™ Test NetBeans™ installation by clicking the icon that appears on the desktop.
|
Opening NetBeans™ took 24 seconds and 1 context switch. This required: a) opening NetBeans™ |
||
Development - Creating the Applet Project In NetBeans™ we click the File --> New Project menu to obtain:
We then click Next > to obtain:
|
Creating
Applet Project took 19 seconds and
3 context switches. This required: a) Select Java Class |
||
Development - Open Applet Packages These
actions produce the following outcome in NetBeans™.
|
Opening the
packages took 6 seconds and
1 context switch. This required: a) opening 4 packages |
||
Development - Create Applet Form Now we produce a simple test applet. Right click the Wave Project and create a JApplet Form. JApplets are from the Sun Swing package and have more up to date extensibility than Applets from the older awt package.
|
Creating
the JApplet Form took 21 seconds and
3 context switches This required: a) selecting JApplet Form |
||
Development - Observe Form Design and Source Code Now everything
comes alive. You might want to get all excited. Notice
that Wave.Java™ is in a subpackage named myWavePackage. |
Opening Wave.Java™
in Form Design mode took 12 seconds and
2 context switches This required: a) observing Form Design |
||
Development - Build Trivial Applet It is a good idea to always test everything."In software engineering positive and negative controls are your best friend." I stole this saying from my friend Barry Hurlburt who does science. The idea is the same. Before continuing we ask NetBeans™ to build the project using menu: Build --> Build Main Project. This compiles the sources, creates the jar files and works a number of minor miracles, some of which we need to know about. The function key F11 does this for free in the Kris Kristofferson Bobby McGhee nothing left to lose sense.
The first minor miracle: NetBeans™ reminds us we need to set which project we are currently working on:
|
The first build took 11 seconds. Subsequent builds took 8 seconds and 3 context switches This required: a) Selecting Build Item |
||
Development - Savor First Build The build is successful.
|
Savoring our success takes 5 seconds and 1 context switches This required: a) Savoring Build |
||
Development - Run Build in Applet Viewer Now we can run the build:
The second minor miracle: NetBeans™ runs the applet in a special applet viewer.
The result is trivial since we haven't equipped the jApplet to do anything. But it works. |
Running the build in the applet viewer took 3 seconds and 4 context switches This required: a) Selecting Run Item |
||
Development - Add "Hello World" JLabel to Applet Returning to the visual editor, we can toggle between the form designer view and the source code view. To make the applet say, "Hello World", we first click on the JLabel button in the Swing Palette as shown. We then click on the form to instance the label.
|
Creating the label took 10 seconds and
2 context switches This required: a) Selecting Swing Label |
||
Development - Changing the Applet Layout To get the label to behave predictably, we choose a different layout:
|
Changing the layout took 7 seconds and 1 context switch This required: a) Selecting New Layout |
||
Development - Sizing and Placing the Applet Label Then the label can be sized and placed appropriately.
The different layout options were designed with good intentions - those of being able to adapt to unknown layout circumstances. This generality has not worked out well for designers who just want to, "put that there", which is the proper role for humans in the design loop. Absolute layout is a step in the right direction.
|
Sizing and placing the label took 26 seconds and
3 context switches This required: a) Selecting Label |
||
Development - Changing Label Value and Alignment We can change the label's value to, "Hello World" and the horizontalAlignment to CENTER.
|
Changing the label's value took 19 seconds and
3 context switches This required: a) Selecting Label |
||
Development - Refer to Documentation We
can quickly access the documentation by RIGHT-CLICKING the mouse after
selecting a code fragment.
The requested
documentation now appears in our companion Firefox™ browser.
|
This step took less than 24 seconds and
4 context switches This required: a) Selecting Menu Item |
||
Development - Establishing The Edit-Compile-Look (ECL) Testing Cycle In the
sections that follow, we will test and deploy our trivial "Hello
World" applet in escalating steps. The idea is to catch errors as quickly as possible. The steps for applet testing and deployment are: |
|||
Development - Testing the Applet Form There is a button in the form design tray that executes a consistency test on the form itself.
Sometimes
the test form is scrunched up, but still works. Resize the form to
make sure it is working. |
This
step took less than 1.0 seconds and
3 context switches This required: a) Selecting Test Button |
||
Development - Build, Run and View the Applet in Applet Viewer Pressing the F11 key to build and then Shift + F6 to run yields:
|
Building and running in succession took 22 seconds and 6 context switches This required: a) Pressing Build Key |
||
Subsequent Build and Runs This is
the second test in our escalating ECL test cycle. ![]() |
This
step took 3.5 seconds and 4 context switches This required: a) Pressing Build Key |
||
Development - Testing the Applet with Codebase HTML File NetBeans™ produces an HTML file with an applet tag
that includes a full codebase qualification. Double clicking on the html file in NetBeans™ opens it in the source editor:
|
This step
took 18 seconds and 3 context switches This required: a) Find HTML File |
||
Development - Saving HTML File There
are three views of a given project, File, Project, and Runtime.
The trouble with the current location of this
HTML file is that it will be recreated every time a "Clean and
Build" is done.
In other words, the Wave.html file in our src directory will now be swept forward to the build directory each time we press F11. Now we have established the repeating component of our design cycle:
|
This step
took 18 seconds and 4 context switches This required: a) Find build HTML File |
||
Development - Testing Applet with HTML File + JAR File As your application become more sophisticated
you will have several files, one for each class or object in your project It also removes the longish filename path dependence
we saw above.
When we build, our changes get saved automatically.
This is a nice feature if you wanted those changes. |
Changing from an absolute codebase to a jar file
took 43 seconds and
2 context switches This required: a) Return to HTML File |
||
Deploying Applets that Use Absolute Layouts We are almost ready, but now we have to run one of those strange senseless stone-age errands. We have to include the class files for absolute layout with our build in order for our deployed HTML applet files to work. For some good historical reason, this turns out to be a time wasting hassle. Let me spare you the details and give you just enough to known the pain without feeling it. Figuring out what was actually wrong and what to do about it took four hours. I can shave that to 4 minutes and 19 seconds. The fix is covered in Appendix 1. |
. It takes 4 minutes and 19 seconds to implement the absolute layout fix
and |
||
Development - Test Final Local Applet Finally! We are ready to run the local html file. Remember this right click viewing trick. We will use it often.
This produces the following result:
|
This step
took 2.1 seconds and 5 context switches This required: a) Select View Menu Item |
||
Development - Exit NetBeans We are almost ready to deploy the applet to our server and test it remotely. Since NetBeans™ locks the jar file from other applications, we have to Exit NetBeans™ to release the lock. Simply closing the project will not work.
|
This
step took 7.2 seconds and 2 context switches This required: a) Exit NetBeans™ |
||
Development - Upload the Applet Files to Server
|
This
step took 24.6 seconds and 4 context switches This required: a) Open FTP Application |
||
Development - Test the Deployed Applet It works!
|
This step
took 18.0 seconds and 5 context switches This required: a) Open Browser |
||
| This is the end of the experiment. Results are summarized below | |||
Results
|
|||
Conclusion At the outset I believed that accomplishing the most development operations in the lowest number of context switches was the best metric for software productivity. It now appears that the context switching rate itself is useful for measuring productivity. It is clear that the user is capable of switching contexts far more rapidly than the current generation of machines and IDE's. Two categories of tasks were studied, System Preparation and Applet Development. An additional critical category of task emerged and that is User Preparation. User Preparation was left out of this experiment completely. Here is its relevance. A user who does not know what to do next is stuck until they figure that out. This can take seconds, minutes, hours, days, months, years or never. A user who knows what to do next is the most important single factor in productivity. This factor was not measured at all in this study, but will be addressed in further time and motion experiments dealing with applet conversion. By measurement the fastest context switching rate observed was 3.0 per second. The actual figure is probably larger, if "Kell Factor" is the gating issue. "Kell Factor", a term borrowed from video engineering, is taken to mean the time that it takes for a user to perceive that a change has taken place in the system and respond accordingly. Eventually
it would be desirable to identify and rank the cost of a context switch
by type. Knowing this will enable us to streamline the development cycle
and improve the rate and ease of software development. |
|||
Useful References Getting past Hello World is beyond the scope of this experiment, but you may find the following references excellent starting points.
|
|||
Acknowledgements The ongoing support of my family and technical colleaguee Marilyn Fulper
are gratefully acknowledged. |
|||
| Last updated May 29, 2005 |