Development of the Cocomo Tool
Java documentation
The cocomo tool was written in Java which is a C++ like object oriented language. Writing in java was easy to learn because of all the documentation online.
We made a copy of some of the current interesting documentation here:
- The 1.0 API Documentation which has been a great help
- The Java Language Tutorial
- The Java Language Environment: A White paper
More information can be found at sun's java site (www.javasoft.com).
We used JDK-1_0-solaris2-sparc.tar.gz on a sparc system running SunOS 5.4 (Solaris).
Java building
Java is a language that is (sort of) platform independed. This means that
you can run Java programs on multiple architectures with different operating systems without having to recompile the program.
The interpretator however is platform dependent.
Java code is first translated into a bytecode by the Java compiler. This process can take some time because it uses a multi-pass system where you can make refferences to methods not defined later in the source.
When the bytecode is executed it is first checked for validity by the loader. This may allso take some time especialy because a lot of packages and classes must be loaded.
Applets vs. Applications
In Java you can make Applications or Applets.
Applications are standalone programs that have access to all of the packages and resources Java has to offer.
You can make normal programs using Java applications.
Java Applications are run by the a Java interpretor by calling the
'public static void main(String args[])' method.
This method can than make instances of classes and run them
Java Applets are programs that run within a browser and have only limited acces to resources.
Applets do not have acces to the local filesystem and only to the internet host where the Applet came from.
An Applet is run different from and Application in th
at first an instance of the class is made, the method 'public void init()' is called, 'public void start()' is called when the Applet is in the current page and 'public void stop()' is called when the current page changes. When the Ap
plet is removed 'public void destroy()' is called where the final cleanup is done.
Pointers
There are no pointers in java in the sense that they are in C or C++. But in fact all references to objects are pointers and can be changed. This is nessecary to have more than one refference to a single object.
Allthough you cannot do C-like things to pointers like adding some value to them, NULL pointers are not oncommon (as we have noticed) when you have not initiated the object.
Dangling pointers which are common in C and C++ errors are not likely in Java because you do not have to destroy an object yourself. The garbage collector checks all objects and if there are no references to it, it destroys it.
This allso saves a lot of trouble of freeing resources which you have in other languages like C and C++.
Making interfaces
The making of an user interface is not very complicated in java. Using the java.awt package and a LayoutManager windows are easely created with the correct layout. The final layout is system dependent and for that reason LayoutManagers are used to have a
system independent layout control.
The only drawback of useing Layoutmanagers is that it might not turn out as you planned on all of the platforms.
The source of Cocomo Tool
To keep things simple and allow us to work together on different files we put each class in a different file. An other solution could have been to put all classes in a CocomoTool.java file and make only the CocomoTool class public.
The source consists of the following files:
The working of the Cocomo Tool
CocomoTool makes instances of EAF, Language, TCF and UFC upon startup and displays them on request of the user.
Each of these object signals CocomoTool if there was a change in the parameters.
CocomoTool then updates the output of each of the values on the screen.
When one of the extra windows is closed the instances are not removed but just are not displayed on the screen. This alows CocomoTool to get the values of the objects even when they are hidden.
Because we wanted to be able to run our Cocomo Tool as an Application and as an Applet we had to read our files in different ways. If the program is loaded as an Application the list of Languages will be loaded from the local filesystem. otherwise the Lan
guages.list file will be loaded from the site where the .class files came from. The Application version allso has a 'Quit' button.
A class wich can be run as an Applet and as an Application must have 'public static void main(String args[])', 'public void init()', 'public void start()' and 'public void stop()' methods.
The Applet version is simple, in 'init()' the window is initialized and data loaded, in start the results are calculated using the default values, and in 'stop()' all extra windows are hidden.
The Application has to make a window for the Cocomo Tool first, make an instance of CocomoTool, call the 'init()' method, call the 'start()' method and show the window.