Previous
Next
KWIC Implemented with Main/Subroutine Architectural Style
Your Assignment
Modify data representation
You need to modify the way how circular shifts and sorted circular
shifts are represented by the KWIC system. In the new version,
circular shifts should be now represented in the same way as the
original lines, that is:
-
All characters from all circular shifts should be stored in a new
character array. For instance, consider the following original line:
"Akte X". This line has two circular shifts (the first circular shift
is equal to the original line): "Akte X", "X Akte". All characters
from both circular shifts should be stored completely in the new
character array one after another, as shown in the following figure.
-
Shift index is an integer array, which keeps indices of the first
characters of circular shifts stored in the new character array.
-
The sorted shifts are represented with a new integer array
(alpha_index_), keeping indices of shifts from shifts_index_ array. Of
course, indices in the new array are sorted alphabetically.
Modify functionality of the system
You need to provide the existing KWIC system with additional
functionality. The new KWIC system should be able to filter out some
of the circular shifts that are produced. All circular shifts that
start with a number, i.e., all shifts where the first character is a
character between '0' and '9' should be removed from the shifts array
before the sorting starts.
Hint: Add a new module, i.e., a new function to the existing
sytem. The name of the new module can be filter, and it
should be responsible for iterating through the produced shifts and
removing all the shifts that starts with a number. The
main function should call the filter
function right after the circularShift function and just
before the call of the alphabetizing function.
Thus, the
architecture of the new system looks as shown in the following
picture. Note, that the modification in data representation is already
visible in the figure.
Answer understanding questions
Please, answer the following questions:
-
Which modules from the original KWIC system did you need to modify to
implement the new data representation of circular shifts? What
conclusion can you draw here? How does the KWIC system implemented by
means of main/subroutine architecture with shared data withstand
design changes in data representation?
-
Which modules from the original KWIC system did you need to modify to
add filtering function to the system? Was it difficult to add a new
processing component (
filter function) accessing the
shared data? Can we conclude here that the KWIC system with
main/subroutine architecture with shared data is robust to desing
changes in system's function (assuming that new functions access the
shared data)?
Hints:
-
Modules in the case of main/subroutine architectural
style are functions.
-
The original KWIC system was composed out of 5 modules (functions). If
you needed to modify 2 or more of the original modules (that is 40% or
more of the original code) to implement a certain modification that
means that the style is NOT robust to design changes requested in the
modification.
-
If you needed to modify only 1 module from the original system (do not
count here new modules that you added), then the style is robust to
design changes requested in the modification.
-
Do not write esseys! Concise, small and simple answers are preferred!
Previous
Next