# SA-Unit-2-Case-studies

```Case studies
1
www.bookspar.com | Website for Students |
VTU NOTES | QUESTION PAPERS | NEWS |
RESULTS
Architectural styles and
CASE STUDIES
KeyWord
In Context -KWIC
Instrumentation Software
Mobile Robotics
Cruise Control
Three vignettes in mixed style
www.bookspar.com | Website for Students |
VTU NOTES | QUESTION PAPERS |
NEWS | RESULTS
2
KWIC
www.bookspar.com | Website for Students |
VTU NOTES | QUESTION PAPERS | NEWS |
RESULTS
3
THE
KEYWORD IN CONTEXT PROBLEM
The KWIC 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 &quot;circularly shifted&quot; 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.

www.bookspar.com | Website for Students
| VTU NOTES | QUESTION PAPERS |
NEWS | RESULTS
4
KEYWORD
IN
CONTEXT
DESIGN CONSIDERATIONS
(KWIC):
Changes in algorithm:
For example, line shifting can be performed
i)
on each line as it is read from the input device
ii)
on all the lines after they are read
iii)
on demand when the alphabetization requires a
new set of shifted lines.

www.bookspar.com | Website for Students
| VTU NOTES | QUESTION PAPERS |
NEWS | RESULTS
5
KEYWORD IN CONTEXT (KWIC):
DESIGN CONSIDERATIONS

www.bookspar.com | Website for Students
| VTU NOTES | QUESTION PAPERS |
NEWS | RESULTS
Changes in data representation:
For example, lines can be stored in various ways.
circular shifts can be stored explicitly or
implicitly (as index and offsets).
6
KEYWORD IN CONTEXT (KWIC):
DESIGN CONSIDERATIONS
Enhancement to system function:
 Modify the system to eliminate circular shifts
that starts with certain noise words (such as &quot;a&quot;,
&quot;an&quot;, &quot;and&quot;, etc.).
 Change the system to be interactive, and allow
the user to delete lines from the lists.

www.bookspar.com | Website for Students
| VTU NOTES | QUESTION PAPERS |
NEWS | RESULTS
7
KEYWORD
IN
CONTEXT
DESIGN CONSIDERATIONS
(KWIC):
Performance: Both space and time.
 Reuse: To what extent can the components serve
as reusable entities.

www.bookspar.com | Website for Students
| VTU NOTES | QUESTION PAPERS |
NEWS | RESULTS
8
KEYWORD IN CONTEXT (KWIC):
SOLUTIONS
1: Main program/subroutine with shared data.
 2: Abstract data types.
 3: Reactive integration.
 4: Dataflow.

www.bookspar.com | Website for Students
| VTU NOTES | QUESTION PAPERS |
NEWS | RESULTS
9
KEYWORD IN CONTEXT (KWIC):
SOLUTIONS 1
(MAIN PROGRAM/SUBROUTINE WITH SHARED DATA. )
This solution decomposes the problem according
to the four basic functions performed:
 Input: inputs and stores characters
 Shift which reads characters/writes index
 Alphabetizer: alphabetizes index
 Output: prints alphabetized index

www.bookspar.com | Website for Students
| VTU NOTES | QUESTION PAPERS |
NEWS | RESULTS
10
SOLUTION 1: MAIN
PROGRAM/SUBROUTINE
With shared memory
 Master control calls

www.bookspar.com | Website for Students
| VTU NOTES | QUESTION PAPERS |
NEWS | RESULTS
Input, which inputs and stores characters
 Circular Shift, which reads characters/writes index
 Alphabetize, which alphabetizes index
 Output, which prints alphabetized index

11
KWIC: MAIN PROGRAM /SUBROUTINE
WITH SHARED DATA SOLUTION
www.bookspar.com | Website for Students
| VTU NOTES | QUESTION PAPERS |
NEWS | RESULTS
12
KWIC: SHARED DATA SOLUTION

It decomposes the problem into 4 basic functions

Input, Shift, Alphabetize, output
www.bookspar.com | Website for Students
| VTU NOTES | QUESTION PAPERS |
NEWS | RESULTS
Computational Components are coordinated as
subroutines by a main program.
 Computations can share the same storage.
 This allow efficient data representation.
 Communication
between
the
computational
components and shared data is an unconstrained
-------------------
13
www.bookspar.com | Website for Students
| VTU NOTES | QUESTION PAPERS |
NEWS | RESULTS
--------------------------------------------------------------------- Serious drawbacks in handling changes:
 A change in data storage format will affect
almost all of the modules.
 Changes in algorithm and enhancements to
system function are not easily handled.
 Reuse is not well-supported because each module
of the system is tied tightly to this particular
application
14
KWIC: ABSTRACT DATA TYPES
It decomposes the system into a similar set of five
modules.
 Data is no longer directly shared by the computational
components.
 Each module provides an interface that permits other
components to access data only by invoking procedures
in that interface.

www.bookspar.com | Website for Students
| VTU NOTES | QUESTION PAPERS |
NEWS | RESULTS
15
KWIC:
SOLUTION 2: ABSTRACT DATA TYPES
Input
Set
char
Char
Output
Word
Characters
Setup
Set
char
Char
Word
Circular shift
alph
i-th
www.bookspar.com | Website for Students
| VTU NOTES | QUESTION PAPERS |
NEWS | RESULTS
Master control
Alphabetic shift
16
KWIC:
SOLUTION 2: ABSTRACT DATA TYPES
 Data
encapsulated in objects


Changes in algorithms and data
representation in individual components don't
affect other components.
More reuse support.
 Drawbacks

Changes in functionality can be difficult

might involve components modification or addition
www.bookspar.com | Website for Students
| VTU NOTES | QUESTION PAPERS |
NEWS | RESULTS

is not shared anymore
17
KWIC
SOLUTION 3: IMPLICIT INVOCATION
Output
Input
Circ shift
Insert
Delete
Lines
i-th
Alphabetize
Insert
Delete
i-th
Shifted lines
www.bookspar.com | Website for Students
| VTU NOTES | QUESTION PAPERS |
NEWS | RESULTS
Master control
18
KWIC
SOLUTION 3: IMPLICIT INVOCATION
Uses a form of component integration based on
shared data similar to first solution.
 Interface to the data is more abstract.
 Computations are invoked implicitly as data is
modified.
 An event will be sent to the shift module whenever
there is new line.
 This allows it to produce circular shifts
 This causes the alphabetizer to be implicitly
invoked

www.bookspar.com | Website for Students
| VTU NOTES | QUESTION PAPERS |
NEWS | RESULTS
19
 Supports functional enhancements to the
system.
 Additional modules can be attached
 Supports reuse.
 Uses more space.

www.bookspar.com | Website for Students
| VTU NOTES | QUESTION PAPERS |
NEWS | RESULTS
20
KWIC
SOLUTION 4: PIPES AND FILTERS
www.bookspar.com | Website for Students
| VTU NOTES | QUESTION PAPERS |
NEWS | RESULTS
21
KWIC
SOLUTION 4: PIPES AND FILTERS
It has 4 filters : Input, shift, Alphabetize and Output.
 Each filter process processes the data and sends it to
the next filter.
 Control is distributed


Each filter can run whenever it has data on which to
compute.
Data sharing between filters is strictly limited on
pipes.
www.bookspar.com | Website for Students
| VTU NOTES | QUESTION PAPERS |
NEWS | RESULTS

22
KWIC
SOLUTION 4: PIPES AND FILTERS
www.bookspar.com | Website for Students
| VTU NOTES | QUESTION PAPERS |
NEWS | RESULTS
 It maintains the sensitive flow of processing
 Supports reuse-each filter can function in isolation
 New function can easily be added to the system by
inserting filters at the appropriate points.
 Easy to modify-each filters are logically independent
 Virtually impossible to modify the design to
support interactive system.
 Uses space inefficiently –since each filter must
23
copy all of the data to its output ports.
COMPARISON
Abstract
data type
Implicit
invocation
Pipe and
filter
Change in
algorithm
-
-
+
+
Change in data
representation
-
+
-
-
Change in
function
-
-
+
+
Performance
+
+
-
-
Reuse
-
+
-
+
www.bookspar.com | Website for Students
| VTU NOTES | QUESTION PAPERS |
NEWS | RESULTS
Shared
data
24
NEXT…
Instrumentation Software
www.bookspar.com | Website for Students
| VTU NOTES | QUESTION PAPERS |
NEWS | RESULTS
25
```