INF 212 Modularity Instructors Crista Lopes Copyright Instructors

  • Slides: 20
Download presentation
INF 212 Modularity Instructors: Crista Lopes Copyright © Instructors.

INF 212 Modularity Instructors: Crista Lopes Copyright © Instructors.

Outline The 2 sides of Modularity Today: Modularity and Style in the other Arts

Outline The 2 sides of Modularity Today: Modularity and Style in the other Arts Some Styles

Modules as physical components

Modules as physical components

Modules as conceptual units

Modules as conceptual units

Software Systems – Your Brain. . .

Software Systems – Your Brain. . .

Software Systems – Your Code. . .

Software Systems – Your Code. . .

Your brain and Your code Suggestion for thoughts Expression of thoughts using PL

Your brain and Your code Suggestion for thoughts Expression of thoughts using PL

How to Divide the Problem? ? (*) This is not a trivial question, and

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.

PLs and Modularization PLs are the materials of expression Suggest ways of thinking, ordering,

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. . .

A very old issue Expressing one’s thoughts using some language and materials Understanding the

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 STYLE STYLE

PLs and Styles PLs encourage styles of expression, sometimes quite strongly Often the style

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

Styles in the other Arts Pachelbel Canon in D Original 18 styles (piano) A

Styles in the other Arts Pachelbel Canon in D Original 18 styles (piano) A few more (guitar) Exercises in Style, R. Queneau

When CS rediscovered the issue Parnas “On the criteria to be used in decomposing

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

Modularity Easier comprehension of complex problems Systematic resolution: Divide-and-conquer Loose coupling Division of labor

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

Example - KWIC Problem Input: Ordered set of lines, with ordered set of words,

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 1 Quick 12345 2 Brown 12345 3 Fox 123

Example - KWIC Shared Data Master Control Input Circular Shift Text array Alphabetizing Word

Example - KWIC Shared Data Master Control Input Circular Shift Text array Alphabetizing Word index Output Alphabetized index

Example - KWIC Pipe-and-filter (functional) Read input Shift Sort Displa y output

Example - KWIC Pipe-and-filter (functional) Read input Shift Sort Displa y output

Example - KWIC Monadic Read input Shift Sort Displa y output

Example - KWIC Monadic Read input Shift Sort Displa y output

Example - KWIC OOP-ish (data abstraction) Master Control Input Outpu t Line Storag e

Example - KWIC OOP-ish (data abstraction) Master Control Input Outpu t Line Storag e Circula r Shifter Alphabetiz er

Example - KWIC Pub-Sub Input agent listen/announce Output agent Event Manager listen/announce Shift agent

Example - KWIC Pub-Sub Input agent listen/announce Output agent Event Manager listen/announce Shift agent listen/announce Sort agent