CS397C24 Serialization and Beans Labs

Revised May 21, 1998

 

 

Lab 1: Serialization

Serialization is implemented in several places to fulfill Lab 1 requirements. It is used to save a classifier, a case, and associate a classifier with a case. The steps for performing and verifying each of these tasks follows.

 

Creating and Saving a Classifier

To create a classifier, select "New…" from the "Classifier" menu. The classifier editor (shown below) appears….

 

 

Enter a name, e.g., "Automech" and description, e.g., "Diagnoses common automotive problems.". Select the node labeled root. From the "Node" menu, select "Edit…". A specialist editor like the one shown below appears…

 

 

Enter a name and hypothesis for the root node as shown above. Click "OK" to save the changes and dismiss the specialist editor.

The classifier editor window should now look like the one shown below…

 

 

To save the classifier using serialization, select "Save As…" from the "Classifier" menu. You will get a file dialog prompting for a filename. Call the file "automech.classifier". Close the classifier editor to return to the main application window. To verify that the serialization worked, select "Open…" from the "Classifier" menu. In the file dialog that appears, enter "automech.classifier" in the filename field. A classifier editor appears displaying the previously saved classifier.

 

Creating and Saving a Case

Serialization is also used to save cases persistently. To create a new case, select "New…" from the "Case" menu. A case editor like the one below appears…

 

 

Enter a name and description for the case as shown above. Click the set button to select the classifier to use for the case. This causes a file dialog to open, allowing you to select a file containing a classifier. Select automech.classifier (the file you created in the first steps above). This uses serialization to read the classifier in and associate with the new case. To save the case persistently using serialization, select "Save As…" from the "Case" menu. In the file dialog that appears, enter "auto.case" as the filename. Dismiss the case editor and return to the main application window. Now, verify that the case serialization worked by selecting "Open…" from the "Case" menu. A case editor appears displaying the case you just created.

 

Lab 2: Java Beans

Java Beans is used EXTENSIVELY in the diagnostic framework. ALL domain AND user interface classes are implemented using beans on some level. For example, the case editor is a visual bean connected to two domain object beans: a case and a classifier. See the domain object model and UI object model for detailed specifications.

This design provides maximum flexibility for integrating the classifier with other beans. Because all of the classifier components are beans, a developer has two options for integrating them. A developer may take advantage of all the classifier functionality by integrating the user interface beans - providing maximum functionality for minimal effort. A developer may choose to develop her own user interface components, or devlop a "headless" knowledge-based system by integrating only the domain beans.

No explicit instructions are necessary to demonstrate the bean capabilities of the application because every aspect of the system involves beans. Literally every mouse click invokes some operation on some bean. The section below explains how the beans were constructed using IBM's VisualAge for Java.

 

Creating a Visual Bean with VisualAge

 

The figure below shows the tool used to develop the classifier's user interface beans - the VisualAge Visual Composition Editor. It shows the case editor and the connections between the beans that it contains. All GUI elements are beans in VisualAge, including the menus, input fields, and beans. The case editor bean also embeds other classifier beans - a Case, a Classifier, and can open an evaluation results dialog.

Visual programming in VisualAge consists primarily of drawing connections between embedded beans. In the UI shown above, there are three types of connections: event to method, property to property, and parameter.

Event to method connections connect events like actionPerformed (for menus and buttons) to a method of some bean. In the example UI, the actionPerformed event on the "Save As…" menu item is connected to the writeToFile method on the Case bean. When the event is triggered, the method is performed.

A property-to-property connection links two property values together. This connection causes the value of one property to change when the value of the other changes. If the properties are bound, then event-to-method connections can be used to implement synchronization between the properties. In the example UI, the 3 text display elements are properties in the case editor bean that are connected to bound properties in the domain object beans Case and Classifier. When the text field is updated, the corresponding property of the domain bean is synchronized. Likewise, if the domain object changes the text field updates to display the new value.

A parameter connection supplies an input value to the target of a connection by passing either a property's value or the return value from a method. This feature is used to display the results of case evaluation. An event to method connection is fired when the "Evaluate…" menu item is selected. The result of the target method is a vector. This vector is supplied as a parameter to a method to display the evaluation results in an EvaluationResultsDialog via a parameter connection.

The ClassifierMainUI and ClassifierEditorUI beans were constructed using the same mechanisms. Each is shown below.