07 October 2004

Task 2 Lab – Notes:

 

The program PcSystemViewer that I wrote to satisfy the problem statement is not much more than a shell to demonstrate the functionality of the PCComponent class.

PCComponent contains only enough information in its methods to find the data (in a connected database) to instantiate component objects. The object being instantiated knows nothing of the properties of its component until it reads those properties from the database. The class is so general that it is easily extensible. It is not, however, appropriate for real-world data modeling mainly because it has no clean way to represent more than one of any subcomponent reporting to a higher level assembly. (Imagine a Bill of Materials where the QUANTITY field can only have the value '1'. )

Program usage is

java PcSystemViewer

The behavior of the program under normal and error conditions is shown in ProgramRun.doc .


Support material:

The class FiatData generates the database. The database must already have accepted the command

CREATE DATABASE TASK2;

NOTE: The phrase IF EXISTS is a MySQL-specific extension to standard SQL. To use FiatData with other SQL databases, the executeUpdate() statements in method dropAllTables() should delete IF EXISTS. The DROP TABLE statements need to be enclosed in try...catch blocks to handle the result of trying to drop nonexistent tables.