Architecture The outcome of toplevel design reflecting principal



















- Slides: 19
“Architecture” • The outcome of top-level design, reflecting principal design decisions • Can (and should) be modified and updated • Analogous to architecture in buildings – Need a plan before construction begins – Need to reconcile opposing interests and constraints • But the analogy is not very good – In software there is much less specialization – Software is much more malleable and easy to fix later (even subject to evolutionary development)
Principal Design Decisions • Structure (e. g. classes and inheritance) • Functional behavior (e. g. sequencing of operations) • Communication mechanisms (e. g. events vs. procedure calls) • Non-functional properties (e. g. how to achieve reliability) • Implementation techniques and frameworks
Problem Statement The KWIC (Key Word in Context) 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 word in any line may be identified as the index word. The KWIC index system outputs a listing of all lines with all possible index words, in alphabetical order of the index words.
KWIC Example Database index Keyword listing Indexing story keywords Telling stories Database index Indexing story keywords Keyword listing Telling stories Indexing story keywords Telling stories
Your Task • Design a system that implements the KWIC index • List modules and interfaces between them • No shortcuts (don’t use libraries that do everything) • What are the main considerations (why done this way)
D. L. Parnas, “On the criteria to be used in decomposing a system into modules”. Comm ACM 15(12), pp. 1053 -1058, Dec 1972 Major contributor to information hiding and modularization (this paper) Advocate of software development as an engineering discipline Including good documentation! Opponent of “star wars” Fellow of ACM, IEEE
1970 s Flow-Chart Based Solution Master control Read input data Cyclic shift index Alphabetize manipulation with pointers Shared memory Output data
More Common KWIC Format Database Indexing Keyword story Telling Indexing Chang e only output modul e Database index Indexing story keywords Keyword listing keywords listing stories story keywords Telling stories
Ignoring Stop Words • Provide list of common words that should not be indexed – The – And –A – Of – It – In – As – This Filter t hem o ut in cycli c shifte r modul e • The output should not include lines with these words identified as index words
Identifying All Keywords • All at once – Create multiple copies of each line and store them • Possible alternative: incremental – Create shifted copies of lines upon request – Not compatible with flow s Useful alternative e and c a f r e t in n o d n e p de dule o m g in ll a c t c e f f a may
Alphabetizing Approach • All at once – Alphabetize the whole list – Then output the result • Alternative: incremental Hidden on ly if interface p rovides an iterator; al ternatives not suitabl e if providing a list – Upon request, search for first line – Delete it after use • Alternative: mixed – Partition data into sorted segments like quicksort – Alphabetize each segment when needed
Alternative ADT Solution Master control Read input insert Alphabetize Cyclic shift iterate insert copies provide order Output iterate interface defining logical operations Line storage
Another Alternative Solution Master control iterator Read input insert Alphabetize Cyclic shift iterator Line storage Output lines implementation can copy lines or generate them on demand
Another Alternative Solution Master control Dictionary (alphabetized) Read input store lines store index Cyclic shift iterator Line storage read index Output extract lines
Design Competitions • There is more than one solution • Different solutions have different strengths and weaknesses • Idea: use multiple design teams in parallel – Common in other fields, e. g. architecture • Discuss pros and cons of designs • Combine solutions if appropriate
Storage Format • In first approach this is exposed to all modules – All need to know how to manipulate pointers • In second approach this is hidden – Line storage interface is naturally in lines – Can also support words or characters • Importantly can select different storage media – In memory – Swap to disk as needed – Store on the cloud • Might impact performance
Information Hiding • Provide possibility of easy adaptation – Design decisions isolated within modules – Using a module is oblivious to the decision to the chosen implementation) • Provide possibility of easy extension • Do not add complexity in order to do so – Avoid YAGNI (You Ain’t Gonna Need It) (=
Architecture and Modules • Defined by interfaces • Just what a user needs to know and no more – What it does and how to us it – Not how it is implemented • Just what an implementer needs to know and no more – What it needs to do – Not how or why it will be used – Free to choose implementation