Following the previous lectures that focus on the practical uses of good and bad practices, we frame this practices in the context of the developers' cognitive characteristics. We first recall that developers' use sight first and foremost to acquire and reason about their systems. Then, we cast the use of patterns by developers and then discuss the visual system, memory models, and mental models.
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Software Design Patterns in Theory
1. Some Theory and Practice on
Patterns – In Theory
Yann-Gaël Guéhéneuc
NII, Tokyo, Japan
12/02/14
This work is licensed under a Creative
Commons Attribution-NonCommercialShareAlike 3.0 Unported License
20. Visual System
Region
analysis
– Distinguish items based on their regions
Zhuolin Jiang and Larry S. Davis ; Submodular Salient Region Detection ;
Conference on Computer Vision and Pattern Recognition, IEEE, 2013
20/216
21. Visual System
Items
grouping
– Gestalt theory
• Gestalten: to put in form, to give structure
Fritz Perls
*Berlin, July 8, 1893
†Chicago, March 14, 1970
21/216
61. Memory Models
Brooks,
1978
– Problem domain
– Executing program
– Knowledge domains
• Hypothesis-and-verify process
• Importance of documentation
61/216
62. Memory Models
Brooks,
1978
– Problem domain
– Executing program
– Knowledge domains
• Hypothesis-and-verify process
• Importance of documentation
62/216
63. Memory Models
Soloway,
1983
– Experts’ knowledge that novices do not have
• Programming plans
– RUNNING TOTAL LOOP PLAN
– ITEM SEARCH LOOP PLAN
–…
• Rules of programming discourse
– An IF should be used when a statement body is guaranteed
to be executed only once and a WHILE used when a
statement body may need to be repeatedly executed
–…
63/216
65. Memory Models
Soloway,
1983
An IF should be used when a statement body is guaranteed
to be executed only once and a WHILE used when a
statement body may need to be repeatedly executed
65/216
66. Memory Models
Soloway,
1983
An IF should be used when a statement body is guaranteed
to be executed only once and a WHILE used when a
statement body may need to be repeatedly executed
66/216
67. Memory Models
Soloway,
1983
An IF should be used when a statement body is guaranteed
to be executed only once and a WHILE used when a
statement body may need to be repeatedly executed
67/216
68. Memory Models
Soloway,
1983
An IF should be used when a statement body is guaranteed
to be executed only once and a WHILE used when a
statement body may need to be repeatedly executed
68/216
69. Memory Models
Pennington,
1987
– Multiple abstractions for computer programs
•
•
•
•
(COBOL but may be true for other languages)
Abstraction of function
Abstraction of data-flow
Abstraction of control-flow
Abstraction of conditionalised actions
69/216
80. Memory Models
Van
Mayrhauser, 1995
– From previous works by
•
•
•
•
•
•
•
Pennington
Soloway et al.
Rist
Van Mayhauser and Vans
Letovsky
Brooks
Schneiderman and Mayer
80/216
88. Mental Models
“The image of the world around us, which we
carry in our head, is just a model. Nobody in
his head imagines all the world, government
or country. He has only selected concepts,
and relationships between them, and uses
those to represent the real system.”
—Jay Wright Forrester, 1971
88/216
103. Mental Models
Minsky,
1974
– Frames
• “data-structure for representing a stereotyped situation”
• “network of nodes and relations” and “slots”
– Frame-systems
• Important actions are transformations between the
frames of a system
• Different frames of a system share the same terminals
(and slots)
– Matching process
103/216
106. Mental Models
Minsky,
1974
– Vision
• A frame, once evoked on the basis of partial evidence
or expectation, would first direct a test to confirm its
own appropriateness
• It would request information needed to assign values
to those terminals that cannot retain their default
assignments
• If informed about a transformation (e.g., an impending
motion), it would transfer control to the appropriate
other frame of that system
106/216
111. Mental Models
Minsky,
1974
– Control
• TOP-DOWN or LATERAL: Should one make a pass
over all the terminals first or should one attempt a
complete, detailed instantiation of some supposedly
most critical one?
• CENTRAL CONTROL: Should a frame, once
activated, "take over" and control its instantiation, or
should a central process organize the operation
111/216
112. Mental Models
Soloway,
1986
– In the context of analyzing problems and
constructing programs
– Goals
• Requirements
• Bugs
– Plans
• “Canned” solutions
• With “meaning”
112/216
113. Mental Models
Soloway,
1986
“Master and novice chess players were shown a
meaningful chess board, and asked to recall the
pieces […]. The masters recalled more of the
pieces than did the novices. Next, the masters
and novices were shown a board in which the
chess pieces were placed randomly on the
board. […] The performance of the masters was
the same as that of the novices.”
—Chase and Simon, 1973
113/216
115. Mental Models
Rich
and Waters, 1990
(IBM’s Harlan Mills idea of
“chief programmer teams”)
“[T]o provide software engineers with intelligent
assistance.”
(p. 2)
“The intended interaction between a software
engineer […] is modeled after interaction with a
human assistant.”
(p. 2)
115/216
116. Mental Models
Rich
and Waters, 1990
“Between the engineer and the Apprentice […],
the key to effective cooperation is shared
knowledge.”
(p. 4)
– Shared knowledge
• About the system being worked on
• About concepts of software engineering
Clichés
116/216
117. Mental Models
Rich
and Waters, 1990
“[An algorithmic] cliché contains both fixed parts
and parts that vary from one occurrence of the
cliché to the next […], [it] may also include
constraints […].”
(p. 12)
“Non-algorithmic clichés are represented […]
using standard frame-based knowledge
representation techniques […].”
(p. 21)
117/216
118. Mental Models
Rich
and Waters, 1990
– Key properties of algorithmic clichés
•
•
•
•
Canonical form
Language independence
Convenient manipulation
Expressiveness
– A representation of clichés
The Plan Calculus
118/216
119. Mental Models
Rich
and Waters, 1990
“The Plan Calculus is intended to be a blueprint
language for software.”
(p. 29)
• Formal representation for
– Programs
– Algorithmic clichés
Subroutines
Flowcharts
Program schemas
Program generators
Macros
Flowchart schemas
Formal grammars
Program transformation
Plan calculus
Logic
Data abstraction
119/216
123. (On Gaming…)
Visual system
Memory models
Mental models
http://arstechnica.com/science/2014/02/how-action-games-can-improve-our-visual-skills/
123/216
124. (On Gaming…)
Visual system
Memory models
Mental models
http://arstechnica.com/science/2014/02/how-action-games-can-improve-our-visual-skills/
124/216
125. (On Gaming…)
Visual system
Memory models
Mental models
http://arstechnica.com/science/2014/02/how-action-games-can-improve-our-visual-skills/
125/216
126. (On Gaming…)
Visual system
Memory models
Mental models
“[G]amers [were] better at picking out details in a
cluttered scene”
http://arstechnica.com/science/2014/02/how-action-games-can-improve-our-visual-skills/
126/216
127. (On Gaming…)
Visual system
Memory models
Mental models
“[G]amers [were] better at picking out details in a
cluttered scene”
“[G]amers were able to produce accurate
estimates [of relative counts]”
http://arstechnica.com/science/2014/02/how-action-games-can-improve-our-visual-skills/
127/216
128. (On Gaming…)
Visual system
Memory models
Mental models
“[G]amers [were] better at picking out details in a
cluttered scene”
“[G]amers were able to produce accurate
estimates [of relative counts]”
“Gamers found it easier to perform mental rotations
of geometric shapes”
http://arstechnica.com/science/2014/02/how-action-games-can-improve-our-visual-skills/
128/216
132. Schema Theory
“This comprehensive situation is an
interrelation of events and entities, and is
stored in an internal data structure that can
be activated by recognizing its typical
features. Such data structures, or schemas,
are mental representations in an individual’s
mind.”
—Kohls and Scheiter, 2008
132/216
133. Schema Theory
“This comprehensive situation is an
interrelation of events and entities, and is
stored in an internal data structure that can
be activated by recognizing its typical
features. Such data structures, or schemas,
are mental representations in an individual’s
mind.”
—Kohls and Scheiter, 2008
133/216
134. Schema Theory
“Human brains operate fundamentally in
terms of pattern recognition rather than of
logic. They are highly constructive in settling
on given schema and at the same time are
constantly open to error.”
—Edelman, 2006
(With minor adaptation)
134/216
137. Schema Theory
Piaget,
1969
– Schema and associated processes
• From Plato and Aristotle: essential commonalities,
basic properties that are distinctive of an object
To Kant: link from stimuli to “pure” concepts
– Perceived chair vs. “ideal” chair
– No a-priori knowledge
• Gick and Holyoak: learning by examples and problem
solving (like in mathematics)
137/216
138. Schema Theory
Piaget,
1969
– Schema and associated processes
• Abstract representation of multiple instances of the
same kinds of
–
–
–
–
–
Concept
Situation
Plan
Behaviour
…
to recognise similar / discriminate dissimilar
experiences, access common concepts, draw
inferences, create goals, develop plans, use skills138/216
139. Schema Theory
Piaget,
1969
– Schema and associated processes
• Variables (or slots or attributes)
• (Constrained) Ranges of values
– People’s experience
– Constants
– Optional or mandatory
• Constraints among variables
and their values
139/216
140. Schema Theory
Piaget,
1969
– Schema and associated processes
• Variables (or slots or attributes)
• (Constrained) Ranges of values
– People’s experience
– Constants
– Optional or mandatory
• Constraints among variables
and their values
140/216
141. Schema Theory
Piaget,
1969
– Schema and associated processes
• Variables (or slots or attributes)
• (Constrained) Ranges of values
– People’s experience
– Constants
– Optional or mandatory
• Constraints among variables
and their values
141/216
142. Schema Theory
Piaget,
1969
– Schema and associated processes
• Variables (or slots or attributes)
• (Constrained) Ranges of values
– People’s experience
– Constants
– Optional or mandatory
• Constraints among variables
and their values
142/216
143. Schema Theory
Piaget,
1969
– Schema and associated processes
• Prototypical object
• Object space and (mental) object generator
143/216
144. Schema Theory
Piaget,
1969
– Schema and associated processes
• Prototypical object
• Object space and (mental) object generator
144/216
145. Schema Theory
Piaget,
1969
– Schema and associated processes
• Prototypical object
• Object space and (mental) object generator
145/216
146. Schema Theory
Piaget,
1969
– Schema and associated processes
• Prototypical object
• Object space and (mental) object generator
146/216
147. Schema Theory
Piaget,
1969
– Schema and associated processes
• Prototypical object
• Object space and (mental) object generator
147/216
157. (Schema Theory Programming)
Papert
worked with Piaget from 1958 to
1963 and afterwards
– Constructionism
• Learning as a reconstruction rather than as a
transmission of knowledge
• Learning is most effective when part of learner’s
activity to build a meaningful product
http://www.lispcast.com/programming-language-stages-of-development
157/216
158. (Schema Theory Programming)
Papert developed the Logo programming language
within the constructionism theory circa. 1967
158/216
159. (Schema Theory Programming)
Explanations
of Logo programming using
a simplified cognitive development model
Corporal Visual Symbolic
– The child learns to see her own perspective from
the outside in the turtle
– The child sees the results of her commands
immediately (cf. chick sexing)
– The child could think of the result of her
commands before their execution
159/216
160. (Schema Theory Programming)
Explanations
of object-oriented programming using the same simplified model
Corporal Visual Symbolic
– The ability to program from the perspective of a
single object at a time
– The ability to think in terms of visual, archetypal
interactions (client-server, MVC, etc.)
– The ability to build abstractions with simple yet
powerful rules and meta-programming
160/216
161. Schema Theory
Rumelhart
and Norman, 1978
– Models of learning
• Comprehension: pattern matching of memorised
schema that cooperates and competes
161/216
162. Schema Theory
Rumelhart
and Norman, 1978
– Models of learning
• Comprehension: pattern matching of memorised
schema that cooperates and competes
162/216
163. Schema Theory
Rumelhart
and Norman, 1978
– Models of learning
• Comprehension: pattern matching of memorised
schema that cooperates and competes
• Animal face
• human face
• Bob’s face
163/216
164. Schema Theory
Rumelhart
and Norman, 1978
– Models of learning
• Comprehension: pattern matching of memorised
schema that cooperates and competes
• Animal face
• human face
• Bob’s face
164/216
165. Schema Theory
Rumelhart
and Norman, 1978
– Models of learning
• Comprehension: pattern matching of memorised
schema that cooperates and competes
• Animal face
• human face
• Bob’s face
165/216
166. Schema Theory
Rumelhart
and Norman, 1978
– Models of learning
• Comprehension: pattern matching of memorised
schema that cooperates and competes
• Animal face
• human face
• Bob’s face
166/216
167. Schema Theory
Rumelhart
and Norman, 1978
– Models of learning
• Comprehension: pattern matching of memorised
schema that cooperates and competes
• Animal face
• human face
• Bob’s face
167/216
168. Schema Theory
Rumelhart
and Norman, 1978
– Models of learning
• Comprehension: pattern matching of memorised
schema that cooperates and competes
• Animal face
• human face
• Bob’s face
168/216
169. Schema Theory
Rumelhart
and Norman, 1978
– Models of learning
• Accretion: specific situation or experience stored in
schemas used to reconstruct original experience
– Episodic memory
– Specific details
169/216
170. Schema Theory
Rumelhart
and Norman, 1978
– Models of learning
• Accretion: specific situation or experience stored in
schemas used to reconstruct original experience
– Episodic memory
– Specific details
곰 세 마리가 한 집에 있어
아빠 곰 엄마 곰 애기 곰
아빠 곰은 뚱뚱해
엄마 곰은 날씬해
애기 곰은 너무 귀여워
170/216
171. Schema Theory
Rumelhart
and Norman, 1978
– Models of learning
• Accretion: specific situation or experience stored in
schemas used to reconstruct original experience
– Episodic memory
– Specific details
곰 세 마리가 한 집에 있어
아빠 곰 엄마 곰 애기 곰
아빠 곰은 뚱뚱해
엄마 곰은 날씬해
애기 곰은 너무 귀여워
Why/How is specific information forgotten/replaced by
generalised knowledge?
171/216
172. Schema Theory
Rumelhart
and Norman, 1978
– Models of learning
• Tuning: modifications to existing schemas
– Variables
– Ranges
– Probabilities
172/216
173. Schema Theory
Rumelhart
and Norman, 1978
– Models of learning
• Tuning: modifications to existing schemas
– Variables
– Ranges
– Probabilities
173/216
174. Schema Theory
Rumelhart
and Norman, 1978
– Models of learning
• Restructuring: ex nihilo / copy of existing schemas
– Schema generation by analogies with existing schema, is-a
– Schema induction from existing schema, has-a
174/216
175. Schema Theory
Rumelhart
and Norman, 1978
– Models of learning
• Restructuring: ex nihilo / copy of existing schemas
– Schema generation by analogies with existing schema, is-a
– Schema induction from existing schema, has-a
175/216
179. Software Patterns
Schemas
– Variables
– Ranges of values
• Forces
– Constraints among
variables and their
values
Possible classes playing this role
plus their relations, implementation…
179/216
181. Software Patterns
Schema
theory
“The pattern is an attempt to discover some
invariant features, which distinguishes good
places from bad places with respect to some
particular system of forces.”
—Christopher Alexander, 1979
181/216
182. Software Patterns
Knowledge
and–or procedure
“The solution part of a good pattern describes
both a process and a thing: the ‘thing’ is created
by the ‘process’.”
—Christopher Alexander, 1979
“Furthermore, a pattern tells about a form not
only what it is but also what it does.”
—Christopher Alexander, 1964
182/216
183. Software Patterns
Space
and generation
“A pattern describes a coherent yet infinite
design space, not a finite set of implementations
in that space.”
—Frank Buschmann, Kevlin Henney,
and Douglas C. Schmidt, 2007
183/216
184. Software Patterns
Use design patterns
–
–
–
–
Composite
Decorator
Observer
…
to generate the
architecture of the
program
184/216
185. Software Patterns
Wholeness
– Quality Without a Name
• Forces
“Having an ideal concept of a thing lets one
judge the beauty of it”
—Kohls and Scheiter, 2008
185/216
187. Software Patterns
“Important assumptions
– That patterns can be codified in such a way that
they can be shared between different designers
– That reuse will lead to “better” designs. There is
an obvious question here of what constitutes
“better”, but a key measure is maintainability”
—Zhang and Budgen, 2012
(With minor adaptations)
187/216
189. Empirical Studies
“Eye movements are uniquely poised between
perception and cognition. They are central to the
function of the visual system, but for such scanning
to be efficient, it cannot be simply a random
sample of the visual world. To be useful, eye
movements must be related to an organism’s
memories, expectations and goals. Consequently,
eye movements are driven equally by bottom-up
perceptual properties of the world and top-down
cognitive processes.”
—Richardson, Dale, and Spivey, 2013
189/216
190. Empirical Studies
“Eye movements are uniquely poised between
perception and cognition. They are central to the
function of the visual system, but for such scanning
to be efficient, it cannot be simply a random
sample of the visual world. To be useful, eye
movements must be related to an organism’s
memories, expectations and goals. Consequently,
eye movements are driven equally by bottom-up
perceptual properties of the world and top-down
cognitive processes.”
—Richardson, Dale, and Spivey, 2013
190/216
191. Empirical Studies
“Eye movements are uniquely poised between
perception and cognition. They are central to the
function of the visual system, but for such scanning
to be efficient, it cannot be simply a random
sample of the visual world. To be useful, eye
movements must be related to an organism’s
memories, expectations and goals. Consequently,
eye movements are driven equally by bottom-up
perceptual properties of the world and top-down
cognitive processes.”
—Richardson, Dale, and Spivey, 2013
191/216
192. Empirical Studies
“Eye movements are uniquely poised between
perception and cognition. They are central to the
function of the visual system, but for such scanning
to be efficient, it cannot be simply a random
sample of the visual world. To be useful, eye
movements must be related to an organism’s
memories, expectations and goals. Consequent,
eye movements are driven equally by bottom-up
perceptual properties of the world and top-down
cognitive processes.”
—Richardson, Dale, and Spivey, 2013
192/216
193. Empirical Studies
“Eye movements are uniquely poised between
perception and cognition. They are central to the
function of the visual system, but for such scanning
to be efficient, it cannot be simply a random
sample of the visual world. To be useful, eye
movements must be related to an organism’s
memories, expectations and goals. Consequent,
eye movements are driven equally by bottom-up
perceptual properties of the world and top-down
cognitive processes.”
—Richardson, Dale, and Spivey, 2013
193/216
205. Empirical Studies
Tobii
1750 eye-tracker
– www.tobii.se
– Non-intrusive (no head mount)
– Two cameras built into a 17 in flat screen
– Records audio and video of a session
– Error rate < 0.5º
– Sampling rate of 50Hz
ClearView
software
205/216
210. Conclusion
“That practices can be codified in such a
way that they can be shared between
different designers”
—Zhang and Budgen, 2012
What
format?
How memorised?
How acquired?
210/216
211. Conclusion
“That practices can be codified in such a
way that they can be shared between
different designers”
—Zhang and Budgen, 2012
What
format?
How memorised?
How acquired?
Schema theory
211/216
212. Conclusion
“That practices can be codified in such a
way that they can be shared between
different designers”
—Zhang and Budgen, 2012
What
format?
How memorised?
How acquired?
Schema theory
Long-term memory
212/216
213. Conclusion
“That practices can be codified in such a
way that they can be shared between
different designers”
—Zhang and Budgen, 2012
What
format?
How memorised?
How acquired?
Schema theory
Long-term memory
Gestalt theory
213/216