case study 1

24
CASE STUDY #1 kwic Dr Reeja S R Professor CSE Dept. SJEC, Vamanjoor, Mangalore

Upload: dr-reeja-s-r

Post on 16-Apr-2017

82 views

Category:

Design


0 download

TRANSCRIPT

Page 1: Case study 1

CASE STUDY #1

kwic

Dr Reeja S RProfessorCSE Dept.SJEC, Vamanjoor, Mangalore

Page 2: Case study 1

CASE STUDY #1

KWIC

Page 3: Case study 1

Key Word In Context

“The KWIC system index system accepts an ordered set of lines, each line is an ordered set of words, and each word is an ordered set of characters.

Any line may be “circularly shifted” by repeatedly removing the first word and appending it at the end of the line.

The KWIC index system outputs a listing of all circular shifts of all lines in alphabetical order.”

Page 4: Case study 1

Evaluation Criteria1. Change in overall processing algorithm:

line shifting - as line read in, on all lines after they are read, or on demand

2. Change in data representation: Store lines as character string or linked list

3. Enhancements: eliminate shifts that start with noise words (“a”,

“the”), allow deletion of lines, make system interactive

4. Performance: space and time.

5. Reuse: to what extent may components be reused?

Page 5: Case study 1

KWIC: Functional Decomposition

• Read input• Create circular shifts• Sort in alphabetical order• Write output

Page 6: Case study 1

Solution #1

Main program/Subroutine with Shared Data

Page 7: Case study 1

KWIC: Solution #1

One subroutine for each of the four functions

Main program “Master control” calls each of the subroutines in turn

The subroutines operates on shared data

Page 8: Case study 1

Solution #1 Main program/Subroutine with shared data

Page 9: Case study 1

Input: reads the input lines and stores in Characters data structure

Circular Shift directly accesses Characters to build Index data structure. Each entry in Index identifies the address of circular shift in Characters.

 

Alphabetizer: directly accesses Characters and Index to build Alphabetized Index. This contains an ordered set of indices into Characters

Output directly accesses Alphabetized Index and Characters to output the ordered, shifted titles

Page 10: Case study 1

Strengths and weakness Strengths:

Efficient use of space (and time) Intuitive appeal -natural solution Enhancements e.g. removing shifts starting with noise

words can be easily accommodated

Weaknesses: Change of data representation affects all modules Not particularly supportive of reuse - Tight coupling with

data structures. Changes to overall processing algorithm –depends on

nature of change.

Page 11: Case study 1

Solution 1

5 criteria to judge each design on:

1. change the overall algorithm? 2. changes to data representation?

3. extend the program functionality? 4. efficient use of space and time?

5. Can the code be easily re-used?

Page 12: Case study 1

Solution #2 Abstract Data Type

Page 13: Case study 1
Page 14: Case study 1
Page 15: Case study 1
Page 16: Case study 1

Strengths and weakness

Strengths: –Data representations can be changed inside

individual modules without affecting others. –Reuse better supported because modules make

less assumptions about others -looser coupling. Weaknesses:

difficult to enhance e.g. How would you remove shifts starting with noise words? Feasible, but potentially messy.

Perhaps more space, and access through interfaces may be slightly slower.

Page 17: Case study 1

Solution 1

5 criteria to judge each design on:

1. change the overall algorithm? 2. changes to data representation?

3. extend the program functionality? 4. efficient use of space and time?

5. Can the code be easily re-used?

Page 18: Case study 1

Solution #3 Implicit Invocation

Page 19: Case study 1

LineStorage 1 : original lines,

LineStorage 2 :all circular shifts.

Input module: read data from a file and store it in LineStorage1

CircularShifter: produce circular shifts and store in the LineStorage2

Alphabetizer: sort circular shifts alphabetically.

Output : print the sorted shifts.

Master control module, responsible for overall control of the system

Page 20: Case study 1

Strengths and weakness

Strengths: Can alter overall processing algorithm by registering on

different events -triggering after each line entered or when all lines entered.

May enhance by adding independent functions e.g. Omit that deletes ‘noisy’ shifts after a Shifted Line insert.

supports change in data representation. Reusable –modules are loosely coupled.

Weaknesses: more space is required e.g. Line, Shifted Line and Sorted

Line buffers.

Page 21: Case study 1

Implicit Invocation

5 criteria to judge each design on:

1. change the overall algorithm? 2. changes to data representation?

3. extend the program functionality? 4. efficient use of space and time?

5. Can the code be easily re-used?

Page 22: Case study 1

Solution #4 Pipes and Filters

Page 23: Case study 1

Strengths and Weaknesses Strengths:

•Intuitive flow of processing. •Supports enhancements by addition of filters e.g.

an omit ‘noisy shift’ filter, or by modifying independent filters.

•Supports reuse, filters operate in isolation.

Weaknesses: how would you interactively delete user-selected

lines Data format has to be agreed between the filters Inefficient use of space. Overall processing algorithm limited to sequential

flow / batch style.

Page 24: Case study 1

Implicit Invocation

5 criteria to judge each design on:

1. change the overall algorithm? 2. changes to data representation?

3. extend the program functionality? 4. efficient use of space and time?

5. Can the code be easily re-used?