Download presentation
Presentation is loading. Please wait.
Published byClifton Homer Bradley Modified over 9 years ago
1
INF 212 Modularity Instructors: Crista Lopes Copyright © Instructors.
2
Outline The 2 sides of Modularity Today: Modularity and Style Style in the other Arts Some Styles
3
Modules as physical components
4
Modules as conceptual units
5
Software Systems – Your Brain...
6
Software Systems – Your Code...
7
Your brain and Your code Expression of thoughts using PLSuggestion for thoughts
8
How to Divide the Problem? ? (*) (*) This is not a trivial question, and you only face it much later, possibly after years of experience in programming. (*) Some people never even face this question, having learnt only one way of thinking.
9
PLs and Modularization PLs are the materials of expression Suggest ways of thinking, ordering, dividing English suggests placing adjectives before nouns E.g. “An inconvenient truth” Latin languages suggest placing adjectives after nouns E.g. “Uma verdade inconveniente” Try doing this in English...
10
A very old issue Expressing one’s thoughts using some language and materials Understanding the deeper structures of artifacts, after analyzing them One Word: STYLE
11
PLs and Styles PLs encourage styles of expression, sometimes quite strongly Often the style one learns first is the one that sticks to our brain, like our mother natural language Language wars are style wars “English is better than French” “Haskell is better than Java” More on utilitarian perspectives later on
12
Styles in the other Arts Pachelbel Canon in D Original Original 18 styles (piano) 18 styles (piano) A few more (guitar) A few more (guitar) Exercises in Style, R. Queneau
13
When CS rediscovered the issue Parnas “On the criteria to be used in decomposing systems into modules” Concrete examples and guidelines for different ways to modularize Primarily how to deal with state We can do it in many ways, now what? Which is better? Parnas suggestion: information hiding should play a role in deciding that Functional programming had been suggesting it all along without formulating the question
14
Modularity Easier comprehension of complex problems Systematic resolution: Divide-and-conquer Loose coupling Division of labor Enables independent evolution and maintenance Reuse High Cohesion Module has single responsibility/purpose
15
Example - KWIC Problem Input: Ordered set of lines, with ordered set of words, with ordered set characters. Any line may be circularly shifted (removing the last word of the line, appending at the beginning) Output: All circular shifts of all lines in alphabetical order Q u i c k 1 2 3 4 5 Q u i c k 1 2 3 4 5 B r o w n 1 2 3 4 5 B r o w n 1 2 3 4 5 F o x 1 2 3 F o x 1 2 3 123
16
Example - KWIC Shared Data Master Control Text array Word index Alphabetized index
17
Example - KWIC Read input Shift Sort Display output Display output Pipe-and-filter (functional)
18
Example - KWIC Read input Shift Sort Display output Display output Monadic
19
Example - KWIC OOP-ish (data abstraction) Line Storage Input Circular Shifter Alphabetizer Output Master Control
20
Example - KWIC Input agent Input agent Shift agent Shift agent Sort agent Sort agent Output agent Output agent Pub-Sub Event Manager listen/announce
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.