kwic project – part 1 mini-project to evaluate architectural patterns(styles) carl chesser ji li...
TRANSCRIPT
KWIC Project – Part 1
Mini-Project to Evaluate Architectural Patterns(Styles)
Carl ChesserJi Li
EECS 761
EECS 761
Overview
• Design– Main-Subroutine– Object Oriented– Pipe and Filter
• Evaluation– Change in algorithm– Change in data representations– Change in functionality– Performance– Reusability
EECS 761
• Design– Main-Subroutine– Object Oriented– Pipe and Filter
• Evaluation– Change in algorithm– Change in data representations– Change in functionality– Performance– Reusability
EECS 761
DesignMain-Subroutine
• Java language• Modules– Each module is a class with one static method– Not utilized as an object instance– KeyWordInContextApplication TextLoader TextRotator TextSorter
EECS 761
• Main: KeyWordInContextApplication– Driving module– Responsibilities:
• Accept the user input (file name to load the textual content)• Validate the user input • Call TextLoader module to load the text from the specified file.• Call TextRotator module to produce all the different rotations
(circular shifts).• Call TextSorter module to produce a sorted listing of all the textual
rotations.• Print the results
DesignMain-Subroutine
EECS 761
DesignMain-Subroutine
• Subroutines– TextLoader Responsibility:
• Takes a file name and loads the contents of the file and returns an ordered listing of strings
– TextRotator Responsibility:• Takes in a string and produces a list of all the rotations and returns
it as a list of strings
– TextSorter Responsibility:• Takes a listing of strings and returns an ordered listing of those
strings which are sorted in a case-insensitive manner
EECS 761
• Design– Main-Subroutine– Object Oriented– Pipe and Filter
• Evaluation– Change in algorithm– Change in data representations– Change in functionality– Performance– Reusability
EECS 761
DesignObject Oriented
• Java language• Classes– KeyWordInContextApplication– FileReader– Phrase– Word– PhraseRotator– PhraseList
EECS 761
DesignObject Oriented
• Classes– KeyWordInContextApplication Responsibility:• Accept and Validate user input • Call FileLoader class to load the text from the specified
file• Call PhraseRotator class to rotate the Phrases• Call PhraseList sorting method to produce a new
PhraseList in a sorted order• Print the results
– Phrase Responsibility:• Decompose a raw string into a collection of Word objects
EECS 761
DesignObject Oriented
• Classes– PhraseList Responsibility:
• Maintain a collection of Phrases and own the logic of sorting the collection
– FileReader Responsibility:• Takes an input and produce a PhraseList representing the
contents of input file
– PhraseRotator Responsibility:• Takes in a Phrase and produces a PhraseList representing all
the unique rotations (…Continued)
EECS 761
• Design– Main-Subroutine– Object Oriented– Pipe and Filter
• Evaluation– Change in algorithm– Change in data representations– Change in functionality– Performance– Reusability
EECS 761
DesignPipe and Filter
• Modules– Rotate Responsibility:
• Takes input stream of text and produces an output stream of all the circular rotations
– Sort Responsibility:• Takes input stream of text and produces an output stream of
the sorted form
– UNIX shell Responsibility:• Produce input stream (cat command)• Provide piping functionality
EECS 761
• Design– Main-Subroutine– Object Oriented– Pipe and Filter
• Evaluation– Change in algorithm– Change in data representations– Change in functionality– Performance– Reusability
EECS 761
Evaluation
• Change in algorithm– Main-subroutine:
• Changes of one or more subroutines that implement the algorithm will be required
• Possibly changes on the sequence of subroutines being called
– Object Oriented:• Only the object implementing the algorithm needs to be updated
– Pipe and Filter:• Only the filter implementing the algorithm needs to be updated
EECS 761
• Design– Main-Subroutine– Object Oriented– Pipe and Filter
• Evaluation– Change in algorithm– Change in data representations– Change in functionality– Performance– Reusability
EECS 761
Evaluation
• Change in data representations– Main-subroutine:
• All modules utilizing this data type would need to be changed
– Object Oriented:• All objects which reference the data type need to be changed • Most primitive types are encapsulated in classes, and therefore
would require minimal change
– Pipe and Filter:• The filter involved with that data type would need to be changed• Other filters consuming the serialization of this data type would
also need to be changed.
EECS 761
• Design– Main-Subroutine– Object Oriented– Pipe and Filter
• Evaluation– Change in algorithm– Change in data representations– Change in functionality– Performance– Reusability
EECS 761
Evaluation
• Change in functionality– Main-subroutine:
• The main program and all of the subroutines may need to be updated
– Object Oriented:• Only the objects related to implement the new functionality will
need to be updated
– Pipe and Filter:• All filters need to be updated
EECS 761
• Design– Main-Subroutine– Object Oriented– Pipe and Filter
• Evaluation– Change in algorithm– Change in data representations– Change in functionality– Performance– Reusability
EECS 761
Evaluation
• Performance (Time)– Testing against large text file
• Text file representation of Les Misérables• 67,724 lines and a total of 567,043 words
– Execution time captured by “time” command• time ./kwic-oo les_miserable.txt > kwic-oo.out
EECS 761
Evaluation
• Performance (Time)
Object oriented and Main-subroutine have better run-time performance than Pipe-and-Filter.
(…Continued)
Runs kwic-oo kwic-procedural kwic-pfRun 1 19.332 18.854 20.672Run 2 19.378 19.075 20.499Run 3 19.399 20.166 20.849Run 4 19.540 19.277 21.170Run 5 18.888 19.262 21.031Average(seconds)
19.3074 19.3268 20.8442
EECS 761
Evaluation
• Performance (Space)– Pipe and Filter space requirement is difficult to capture
• Utilizing separate Java virtual machines
– Main-subroutine would consume less memory than Object Oriented approach• OO approach has a lot more objects, thus more overheads
EECS 761
• Design– Main-Subroutine– Object Oriented– Pipe and Filter
• Evaluation– Change in algorithm– Change in data representations– Change in functionality– Performance– Reusability
EECS 761
Evaluation
• Reusability– Main-subroutine:
• Limited reusability
– Object Oriented:• More abstraction per class• Very reusable• Require additional word for re-assembling
– Pipe and Filter:• All filters as external components are reusable