information hiding in kwic
play

Information Hiding in KWIC system accepts an ordered set of lines, - PDF document

Key Word In Context The KWIC [Key Word In Context] index Information Hiding in KWIC 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


  1. Key Word In Context • “The KWIC [Key Word In Context] index Information Hiding in KWIC 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 15-413: Introduction to Software Engineering the first word and appending it at the end of the line. The KWIC index system outputs a Jonathan Aldrich listing of all circular shifts of all lines in alphabetical order.” - Parnas, 1972 ��������������� KWIC Modularization #1 KWIC Modularization #2 Master Control Master Control Shifts Shifts Alphabetize Input Circular Alphabetize Output Input Output ith(i) Shift Circular Shift Lines cschar(l,w,c) Line Storage getChar(r,w,c) setChar(r,w,c,l) ��������������� ��������������� KWIC Observations Effect of Change? • Change input format • Similar at run time Master Control • Don’t store all lines • May have identical data representations, in memory at once algorithms, even compiled code Shifts Shifts Input Circular Alphabetize Output • Avoid packing 4 Shift • Different in code characters to a word Lines • Understanding • Store the shifts • Documenting directly instead of • Evolving Master Control indexing • Amortize Alphabetize Input Output ith(i) alphabetization over Circular Shift Line cschar(l,w ,c) searches Storage getChar(r,w,c) setChar(r,w ,c,l) ��������������� ��������������� 1

  2. Effect of Change? Other Factors • Change input format • Independent Development • Input module only • Data formats (#1) more complex than data • Don’t store all lines in memory at once access interfaces (#2) • Design #1: all modules • Design #2: Line Storage only • Easier to agree on interfaces in #2 because • Avoid packing 4 characters to a word they are more abstract • Design #1: all modules • Design #2: Line Storage only • Comprehensibility • Store the shifts directly instead of indexing • Design of data formats depends on details • Design #1: Circular Shift, Alphabetizer, Output • Design #2: Circular Shift only of each module • Amortize alphabetization over searches • More difficult to understand each module in • Design #1: Alphabetizer, Output, and maybe Master Control isolation • Design #2: Alphabetizer only ��������������� ��������������� Decomposition Criteria A Note on Performance • Functional decomposition • Parnas says that if we are not careful, • Break down by major processing steps decomposition #2 will run slower • Information hiding decomposition • He points out that a compiler can • Each module is characterized by a design replace the function calls with inlined, decision it hides from others efficient operations • Interfaces chosen to reveal as little as • This is 1972! possible about this • But we still hear silly arguments about how (otherwise better) designs are slower • Smart compilers enable smart designs ��������������� ��������������� Design Structure Matrices Design Structure Matrices • Goal: to capture dependencies in the structure of a design 15-413: Introduction to Software Engineering A, B, and C are design parameters • • A choice about some aspect of a design Jonathan Aldrich • X means row depends on column B is hierarchically dependent on A • • If you change A, you might have to change B as well • Suggests you should make a decision about A first B and C are interdependent • C and A are independent • ��������������� 2

  3. Design Structure Matrices Design Structure Matrices • Lines show clustering into proto-modules • Interface reifies the dependence as a • Indicates several design decisions will be design parameter managed together • Instead of B depending on A, now A and B • True modules should be independent both depend on I • i.e., no marks outside of its cluster • Serves to decouple A and B • Not true here because B (in the B-C cluster) • Think of I as the interface of A depends on A ��������������� ��������������� KWIC Design #1 KWIC Design #1 A D G J B E H K C F I L M Interdependence A - Input Type . of data formats D - Circ Type . G - Alph Type . J - Out Type . B - In Data . X X Many data E - Circ Data X . X dependences H - Alph Data X X . K - Out Data . C - Input Alg X X . True modules F - Circ Alg X X X . I - Alph Alg X X X X . L - Out Alg X X X X . M - Master X X X X . ��������������� ��������������� KWIC Design #2 EDSMs: Considering Possible Changes N A D G J O P B C E F H I K L M • Environment and Design Structure Matrices N - Line Type . • Sullivan et al., ESEC/FSE 2001 A - Input Type . D - Circ Type . Add changes as environmental parameters • G - Alph Type . Note: slightly more concrete than what Sullivan et al. propose • J - Out Type . • Only partially controlled by designer O - Line Data X . X • May affect each other P - Line Alg X X . B - In Data X . X True modules • May affect design decisions in code Dependence C - Input Alg X X X . on interfaces • What interfaces are affected? E - Circ Data X X . X • Information hiding: interfaces should be stable F - Circ Alg X X X . H - Alph Data X . X • What implementations are affected? I - Alph Alg X X X . • Information hiding hypothesis: should be local to a K - Out Data X . X module L - Out Alg X X X X . M - Master X X X X X . ��������������� ��������������� 3

  4. Effect of Change – Design #1 Effect of Change – Design #1 V W X Y Z A D G J B E H K C F I L M Interdependence V - Input Fmt . of changes W - Store Mem . X X X - Char Pack X X . X Y - Shift Store X X . Z - Amortize . A - Input Type . D - Circ Type . G - Alph Type . Unstable J - Out Type . data interfaces B - In Data X X . X X depend on changes E - Circ Data X X . X H - Alph Data X X X X . Algorithms K - Out Data . depend on C - Input Alg X X X X X . data F - Circ Alg X X X X X X . I - Alph Alg X X X X X X X X . L - Out Alg X X X X X X X X . M - Master X X X X X . ��������������� ��������������� Effect of Change – Design #2 Summary V W X Y Z N A D G J O P B C E F H I K L M V - Input Fmt . • EDSMs are a structured way of thinking W - Store Mem . X X X - Char Pack X X . X about the value of design Y - Shift Store X X . Z - Amortize . • Are design decisions isolated to a module? N - Line Type . A - Input Type . Interfaces • How do modules depend on interfaces? D - Circ Type . are stable G - Alph Type . • How are interfaces and code affected by J - Out Type . O - Line Data X X X . X change? P - Line Alg X X X X . B - In Data X X . X C - Input Alg X X X X . Effect of E - Circ Data X X X . X change is F - Circ Alg X X X X . H - Alph Data X X . X localized I - Alph Alg X X X X . K - Out Data X . X L - Out Alg X X X X . M - Master X X X X X . ��������������� ��������������� 4

Recommend


More recommend