Model-Minded Development
George Fairbanks GOTO Berlin 10 November 2016
1
Model-Minded Development George Fairbanks GOTO Berlin 10 November - - PowerPoint PPT Presentation
Model-Minded Development George Fairbanks GOTO Berlin 10 November 2016 1 How does your team build software? 2 How does your team build software? Simple process 1. Get new requirement 2. Write test case 3. Edit code minimally so test
1
2
Simple process 1. Get new requirement 2. Write test case 3. Edit code minimally so test passes 4. Refactor to remove code duplication
3
Simple process 1. Get new requirement 2. Write test case 3. Edit code minimally so test passes 4. Refactor to remove code duplication
4
5
6
Without models 1. Get new requirement 2. Write test case 3. Edit code minimally so test passes 4. Refactor to remove code duplication With models 1. Get new requirement 2. Does it challenge our models? a. E.g., client-server still OK? b. E.g., domain model still OK? 3. Revise models 4. Write test case 5. Revise code to match model
7
Main sections:
8
9
Emphasis added
10
Knowing that Memorized facts
No understanding; no theory
Gilbert Ryle (1949): Knowing How and Knowing That
11
Knowing that Memorized facts
No understanding; no theory Knowing how General theory of addition
Understanding; a theory
Gilbert Ryle (1949): Knowing How and Knowing That
theory ≈ model
12
Knowing that Memorized facts
No understanding; no theory Knowing how Understanding of the program
about any aspect of the program
kluged
13
while (true) {
if (surprise) {refactor theory}; }
future past
Refactor the theory
14
How well I understand ≈ How well theory matches future observations
future past
Refactor the theory
15
while (true) { pick up new requirement; if (surprise) {refactor theory}; }
requirements future past
Refactor the theory
16
requirements future past
Refactor the theory
17
Better understanding Worse understanding
18
Eric Evans, Domain Driven Design, 2004
19
20
[P]rogramming should be regarded as a production
Every feature we add to this geocentric model makes it harder to add the next feature!
21
Without models 1. Get new requirement 2. Write test case 3. Edit code minimally so test passes 4. Refactor to remove code duplication With models 1. Get new requirement 2. Does it challenge our models? a. E.g., client-server still OK? b. E.g., domain model still OK? 3. Revise models 4. Write test case 5. Revise code to match model
22
23
24
?????
25
2??
90
26
29?
90
405
27
291
90
405
45 With scribbles on paper, we can solve problems that don’t fit in our heads
28
problems with “scribbles on paper”
29
problems with “scribbles on paper”
○ What size program can you write in your head?
(our external representation)
30
?????
But not just any scribbles
31
???????
32
4 3 5 1 0 9 5
33
Diagram from Stroop effect, not long division
34
Distributed cognition is fragile: “[D]ifferent representations
dramatic impact on problem difficulty even if the formal structures are the same.”
35
○ You + the scribbles
○ Bad scribbles --> trick fails
○ Use whatever scribbles you want ○ Write whatever code works for you ... what if you are on a team?
36
291
90
405
45 Ann Bob Carl Diane
37
38
Challenge 1: Internal-external
(charts, logs, …) Challenge 2: Team
39
Challenge 1: Internal-external
(charts, logs, …) Challenge 2: Team
Success requires:
40
41
42
43
Domain Solution Math, logic, & friends
44
Domain What your subject matter experts talk about Often: nouns, verbs, and relationships between them Long history in
programming Solution Math, logic, & friends
45
Domain What your subject matter experts talk about Often: nouns, verbs, and relationships between them Long history in
programming Solution The tech known only by software engineers
event queues, data structures Math, logic, & friends
46
Domain What your subject matter experts talk about Often: nouns, verbs, and relationships between them Long history in
programming Solution The tech known only by software engineers
event queues, data structures Math, logic, & friends Theories known across sciences and philosophy
Libraries in every language; core of functional programming
Code bridges internal and external
Remember:
47
Domain
Solution
Math, logic, & friends
○ Sets.difference, not the spelled-out equivalent
48
Reusable models Ad hoc models Domain
Solution
(gang of 4 book)
(Cristina Videira Lopes)
Math, logic, & friends
category theory, metamodeling
49
50
Imagine helping a friend’s startup, doing “design recovery” You are recognizing existing patterns / models
Reusable models must be linked (Sitting in a book they do nothing)
51
○ Speech, whiteboards, docs, code?
○ When do you update them? ○ How strict are you?
52
53
Without models 1. Get new requirement 2. Write test case 3. Edit code minimally so test passes 4. Refactor to remove code duplication With models 1. Get new requirement 2. Does it challenge our models? a. E.g., client-server still OK? b. E.g., domain model still OK? 3. Revise models 4. Write test case 5. Revise code to match model
54
requirements future past
55
Refactor the theory
Challenge 1: Internal-external
(charts, logs, …) Challenge 2: Team
Success requires:
56
57
Domain What your subject matter experts talk about Often: nouns, verbs, and relationships between them Long history in
programming Solution The tech known only by software engineers
event queues, data structures Math, logic, & friends Theories known across sciences and philosophy
Libraries in every language; core of functional programming
58