Motherhood and Apple Pie:
Modularity in Modern
Applications and Tools to
Support it
Steven P. Reiss
Brown University
2013年 4月 1日 Page 1
Slide 2
Slide 2 text
Motherhood and Apple Pie
13/04/01 Page 2
Motherhood and apple pie :: (US)
Principles or values with which few disagree.
Slide 3
Slide 3 text
What is Modularity
Modularity is the ability to view everything
related to a particular concern
on one screen
13/04/01 Page 3
Slide 4
Slide 4 text
What is Modularity
The division of a system into a set
of independent modules
Where modules
Represents a set of related concerns
Communicate in a loosely-coupled
fashion
13/04/01 Page 4
Slide 5
Slide 5 text
Claim
Absolute Modularity is Impossible
13/04/01 Page 5
Slide 6
Slide 6 text
Claim
There are many (very) different concerns
and attempting to be modular for any
reasonable subset is not possible.
13/04/01 Page 6
Slide 7
Slide 7 text
Code Bubbles Demo
Demonstration
13/04/01 Page 7
Slide 8
Slide 8 text
13/04/01 Page 8
Slide 9
Slide 9 text
Concern
The squiggle is sometimes out of place
after a character is typed
13/04/01 Page 9
Slide 10
Slide 10 text
Character Input
• Update editor buffer(s)
• For the character and other effects
• Compile and report errors
• Update underlying AST structure
• Repaint the screen
• Handle layout and reflow
• Handle reformatting
13/04/01 Page 10
Slide 11
Slide 11 text
Character Input
13/04/01
Page 11
Event Dispatch
Update Selection
Auto Indent
Repaint
Request
Document
Dispatch
Auto Completion
Update Other
Editors
Repaint Text
Compute Layout
Update Eclipse
Eclipse AST
Update
Update Error Set
Eclipse Errors
Update
Annotations
Error Notification
Update elements
Update Elements
Slide 12
Slide 12 text
Squiggle Code
On ProblemsUpdatedEvent
• Lock file { Update Problems } Unlock
In update AST structure
• { Clear problems } Update tree { Update problems }
Update Problems
• Maintain the set of active problems (incremental)
• Remove styles for nonexistent problems
• Add squiggle styles for new/cleared problems
When drawing text w/ squiggle style
• Use squiggle paint to underline text
13/04/01 Page 12
Slide 13
Slide 13 text
What Really Happens
Type In Display
13/04/01 Page 13
Slide 14
Slide 14 text
Is This Modularity?
The code is modular ?
The dynamics of the code are not
Which is more important?
13/04/01 Page 14
Slide 15
Slide 15 text
Modular View for Squiggle
Source Code for relevant routines
• The code marked in red
View of what happened at run time
• Where is succeeded
• Where it failed
13/04/01 Page 15
Slide 16
Slide 16 text
Obstructions to Modularity
Black box code (Swing, Eclipse)
Separate interacting processes
Unknown control flow
• Multiple threads running at once
• Callback orders
Our issues are dynamic
• We want modularity to reflect the dynamics
13/04/01 Page 16
Is this Modular?
In terms of code?
Adding new events (NOTIN) was easy
Adding calendar was so-so
Adding a new sensor is messy
13/04/01 Page 19
Slide 20
Slide 20 text
Obstructions to Modularity
Externally imposed modularity
• Multiple languages
• Multiple processes
• Multiple machines
• External code (calendar, obexftp, hcitool)
Part of the program is data
• Passed between applications
• Representing the rule set
13/04/01 Page 20
Slide 21
Slide 21 text
Twitter Data Access
Twitter Web Site demonstration
13/04/01 Page 21
Slide 22
Slide 22 text
13/04/01 Page 22
Slide 23
Slide 23 text
Twitter Data Access
13/04/01 Page 23
Streamer
Data Insertion
Zip/District
Encoder
Web Server
HTML Script CSS
Data
Database
Twitter
Slide 24
Slide 24 text
Twitter Modular Concerns
Support word comparisons?
Optionally normalize the tweet counts?
13/04/01 Page 24
Slide 25
Slide 25 text
Obstructions to Modularity
Multiple programs
Messages (data) are part of the system
Database is a system component
Web application has its own constraints
• Front end: HTML, JavaScript, CSS
• Back end: JavaScript (Node.JS)
• Communication (json via web sockets)
13/04/01 Page 25
Transforms Are Modular
Easy to write
• Average 300 lines each (135-941)
Independent
• Automatic configuration
• Automatic application/detection
• Adding a new transform is trivial
13/04/01 Page 29
Slide 30
Slide 30 text
Problem
Transform sequence blows up
Transform process isn’t modular
13/04/01 Page 30
Slide 31
Slide 31 text
Process Modularity
We need heuristics to guide transforms
• While keeping transforms simple to write
• While keeping transforms independent
• While keeping it easy to add transforms
We must modularize transform dynamics
• As well as their coding
13/04/01 Page 31
Slide 32
Slide 32 text
Obstructions to Modularity
Transformation dynamics not explicit
• Encoded in individual transforms
Heuristics are spread throughout
• Difficult to get a modular view
• Difficult to understand what is going on
Conflicting modularity concerns
13/04/01 Page 32
Slide 33
Slide 33 text
What Have We Learned
I have lots of fun coding
13/04/01 Page 33
Slide 34
Slide 34 text
What Have We Learned
Modularity is in the eye of the beholder
13/04/01 Page 34
Slide 35
Slide 35 text
What We Have Learned
Modularity is Difficult in Today’s Systems
13/04/01 Page 35
Slide 36
Slide 36 text
Challenge
There is no static modular view of a system
13/04/01 Page 36
Slide 37
Slide 37 text
Challenge
Modularity depends on the circumstances
13/04/01 Page 37
Slide 38
Slide 38 text
Multiple View Systems
Modularity can be a function of the view rather
than the code itself
We can view a system in different modular ways
13/04/01 Page 38
Slide 39
Slide 39 text
Pecan
13/04/01 Page 39
Slide 40
Slide 40 text
Garden
13/04/01 Page 40
Slide 41
Slide 41 text
Field
13/04/01 Page 41
Slide 42
Slide 42 text
Desert
13/04/01 Page 42
Slide 43
Slide 43 text
Multiple View Systems
• Scott Myers: SPG-based representation
• CMU Sheets
• IBM Visual Age
• Grundy’s & Hosking’s Mviews
• Hon’s Fluid AOP
• Taivalsaari’s Multidimensional Browsing
• Microsoft’s Intentional Programming
• …
13/04/01 Page 43
Slide 44
Slide 44 text
These Don’t (and Won’t) Work
Database View-Update Problem
• View updates are ambiguous in general
• No single representation supports all views
Program View-Update Problem is worse
• More complex semantics
• More complex representations
13/04/01 Page 44
Slide 45
Slide 45 text
Multiple View Systems
Severely restrict allowed editable views
• Predetermined set, strong restrictions
Explicitly define editing operations
• Making view creation prohibitive
Use read-only views
• Limiting their uses and applicability
13/04/01 Page 45
Slide 46
Slide 46 text
Virtual Modularity
Construct a virtual view by displaying the
subset of the original source relevant to a
particular concern
13/04/01 Page 46
Slide 47
Slide 47 text
Code Bubbles
13/04/01 Page 47
Slide 48
Slide 48 text
Code Bubbles Modularity
Code Bubbles Working Sets
• Are static modular views of a system
• That can be build dynamically
Modularization Techniques
• Show individual functions or components
• Use elision within the components
• Include all types of software artifacts
• Allow save/restore of working sets
13/04/01 Page 48
Slide 49
Slide 49 text
This is Only a Start
• Virtual Modularizations
• Dynamic Modularizations
13/04/01 Page 49
Slide 50
Slide 50 text
Challenges
Paper titles for Modularity 201x
• Automatic creation of modular views
• Dynamic modularity
• Programmer-specified editable modular views
• Static views of a program’s dynamic behavior
• Behavioral modularity
• Dynamic modularity across threads
• Modular views of a multilingual web application
• Automatic creation of dynamic modular views
13/04/01 Page 50
Slide 51
Slide 51 text
Questions / Suggestions
2013年 4月 1日 51
Slide 52
Slide 52 text
What is Modularity?
• Modularity refers to the compartmentalization and inter-relation of the
parts of a software package
• Modularity is designing a system that is divided into a set of functional
units (named modules) that can be composed into a larger application. A
module represents a set of related concerns. It can include a collection of
related components, such as features, views, or business logic, and pieces
of infrastructure, such as services for logging or authenticating users.
Modules are independent of one another but can communicate with each
other in a loosely coupled fashion.
• The use of individually distinct functional units, as in assembling an
electronic or mechanical system.
• Modularity is a general systems concept, typically defined as a continuum
describing the degree to which a system's components may be separated and
recombined.
• Modularity is the property of computer programs that measures the
extent to which they have been composed out of separate parts called
modules.
13/04/01 Page 52
Slide 53
Slide 53 text
Defining Modularity
• What is a module?
• Source code, documentation, design notes,
requirements, …
• What is a concern?
• Whatever we need to look at
• For coding, debugging, understanding, …
13/04/01 Page 53
Slide 54
Slide 54 text
Measuring Modularity
• Various measures of metrics for
dependencies and relationships
• How much work to add, modify, or
understand a concern
• Can you fit the code for one concern on
one screen
13/04/01 Page 54
Slide 55
Slide 55 text
S6 Input Flow
13/04/01 Page 55
SVIWEB
(GWT)
Firewall
XML
Engine
Request
Servlet
Test Builder
Ant Script
Test Prototype File
Tester
Output
Generator
Solution Set
Slide 56
Slide 56 text
Problem
• Adding a new input test feature
• Contracts, security constraints
• Requires Changing
• GWT code, XML, Servlet code, Request
structure, Engine, Test builder, test
prototype, Ant script
13/04/01 Page 56
Slide 57
Slide 57 text
Difficulties
• Modularity constrained by system
• Separate programs are needed
• Communications protocols are part of code
• Multiple languages
• Including non-languages (ant)
• Including data languages
13/04/01 Page 57
Slide 58
Slide 58 text
Challenge
True Modularity is Impossible
13/04/01 Page 58
Slide 59
Slide 59 text
Solutions
Modularity can be a function of the view
rather than the code itself?
13/04/01 Page 59
Slide 60
Slide 60 text
Dynamic Modularity
Show the proper modularization for a
particular dynamic problem
13/04/01 Page 60
Slide 61
Slide 61 text
Dynamic Software Visualization
Visualization for Program Understanding
• Needs to be done in the programmer’s terms
• Needs to be done using proper abstractions
Requires dynamic modular views
13/04/01 Page 61
Slide 62
Slide 62 text
JIVE
13/04/01 Page 62
Slide 63
Slide 63 text
Jove
13/04/01 Page 63
Slide 64
Slide 64 text
Dyper Performance Analysis
13/04/01 Page 64
Slide 65
Slide 65 text
Dymem
13/04/01 Page 65
Slide 66
Slide 66 text
Dylock
13/04/01 Page 66
Slide 67
Slide 67 text
Dynamic Visualizations
Generic tools only solve generic problems
• They don’t solve specific problems
• Generic views aren’t modular
13/04/01 Page 67
Slide 68
Slide 68 text
VELD
13/04/01 Page 68
Slide 69
Slide 69 text
VUIT: Setting Up VELD
13/04/01 Page 69
Slide 70
Slide 70 text
VUIT Events
13/04/01 Page 70
Slide 71
Slide 71 text
Why This Doesn’t Work
The set of thread states is not intuitive nor
is the set of events. The whole process is
too complex.
13/04/01 Page 71
Slide 72
Slide 72 text
Automating the Process
Can we build these models automatically
• In general?
For particular classes of problems
• Threads, Tasks, and Transactions
13/04/01 Page 72
Slide 73
Slide 73 text
Threads, Tasks, Transactions
Automatically
• Find event handlers
• Find significant subtasks
• Find Threads and tasks
• Find Thread Queues
• Based on programmer’s problem definition
Provide customized time-based views
13/04/01 Page 73