KWIC Implemented with Object-Oriented Architectural Style

Your Assignment

Modify data representation

In the current version of the LineStorage class we have the following data structure for storing lines:

You need to modify the data structure for storing lines in LineStorage objects. The new data representation should look as follows:

The following class diagram depicts the modifications you need to implement. Note, that the diagram shows only classes relevant for your current task. All other classes remain the same.

New class diagram

Modify processing algorithm

First, you need to implement an interactive version of the KWIC index system. That means the system won't read lines from a file but lines are inserted interactively by means of a simple command line user interface. Here is a transcript of a sample session:

Further, you need to modify how line shifting is performed. In the current version all lines are read at once, and line shifting is done on all lines at once after they are read. In the new version you need to perform line shifting on each line as it is read from the command line. The following sequence diagram depicts the new situation.

New sequence diagram

Thus in the new system KWIC object controls the command line interface. After a command for adding a line has been issued, the KWIC object invokes readLine method of the Input object. The Input reads the line and passes it to the CircularShifter object by invoking its makeShifts method. After shifts have been made, makeShifts and readLine methods return and the KWIC object is again in charge, waiting for a new command from the user.

Answer understanding questions

Please, answer the following questions:

  1. Which modules from the original KWIC system did you need to modify to implement the new data representation of lines within the LineStorage class? What conclusion can you draw here? How does the KWIC system implemented by means of object-oriented architecture withstand design changes in data representation within a particular module? Is this true for any other object-oriented system?
  2. Which modules from the original KWIC system did you need to modify to implement a new processing algorithm in the system? Can we conclude here that the KWIC system with object-oriented architecture is robust to desing changes in processing algorithm of the system?

Hints:

Valid XHTML 1.0! Valid CSS!