model minded development
play

Model-Minded Development George Fairbanks GOTO London 13 October - PowerPoint PPT Presentation

Model-Minded Development George Fairbanks GOTO London 13 October 2016 Programming! Developers weave models Developers keep in mind many abstract yet complex models that constrain the code they write Domain driven design Design


  1. Model-Minded Development George Fairbanks GOTO London 13 October 2016

  2. Programming!

  3. Developers weave models Developers keep in mind many abstract yet complex models that constrain the code they write ● Domain driven design ● Design patterns ● Architectural styles ● Test Driven Design (TDD) ● Programming styles (functional, OO, procedural, etc.) ● ...

  4. What is Model Minded Development? Model-Minded Development generalizes across DDD, design patterns, architecture, TDD, and coding styles. It’s the general idea behind many specific ones: Modeling should be a first-class activity

  5. Do we really need models? Simple process Imagine discussing with a co-worker 1. Get new requirement He says “Forget this abstract stuff. 2. Write test case Follow this simple process and be happy.” 3. Edit code minimally so test passes 4. Refactor to remove code duplication … repeat forever Answer: Yes we need models, but how can we convince him?

  6. Companies: short and long-term Short-term Long-term Cashflow R&D

  7. Software development: short and long-term Short-term Long-term Deliver Build features models This is my gut feel, maybe yours too

  8. Example behavior with/without models Without models 1. Get new requirement 2. Write test case 3. Edit code minimally so test passes 4. Refactor to remove code duplication

  9. Example behavior with/without models Without models With models 1. Get new requirement 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 2. Write test case 4. Write test case 3. Edit code minimally so test passes 5. Revise code to match model 4. Refactor to remove code duplication

  10. Why model? Need good arguments. For those who don’t share our gut feel, two arguments: 1. Programming is theory building 2. Programming is distributed cognition These describe why you cannot skip modeling

  11. Programming is theory building

  12. [P]rogramming properly should be Peter Naur (1985) regarded as an activity by which the programmers form or achieve a Programming as certain kind of insight, a theory , of the Theory Building matters at hand. This suggestion is in contrast to what appears to be a more common notion, that programming should be regarded as a production of a program and certain other texts. Emphasis added

  13. Understanding addition Knowing that Memorized facts Know that 3+4=7 ● Memorize addition table ● No answers after, eg, 6+6 ● No understanding; no theory Gilbert Ryle (1949): Knowing How and Knowing That

  14. Understanding addition Knowing that Knowing how Memorized facts General theory of addition Know that 3+4=7 Can add small numbers ● ● Memorize addition table More mistakes with larger numbers ● ● No answers after, eg, 6+6 Addition makes numbers bigger ● ● No understanding; no theory Understanding; a theory theory ≈ model Gilbert Ryle (1949): Knowing How and Knowing That

  15. Understanding software Compare: 1. Developer who can report facts about the program 2. Developer who can give impromptu “chalk talk” about any aspect of the program Developer #2 has a rich theory of the program Valuable but rare ● Seed questions: How do we get more “chalk talk ready” developers? ● Does university do enough? ● Do current processes help or hurt? ●

  16. Theory building in science while (true) { observe world; if (surprise) {refactor theory}; } Refactor theory observations past future

  17. Theory building in science Over time, tune theory to match past observations ● Goal: theory matches future observations, many observations without refactoring ● Refactor theory observations past future How well I understand ≈ How well theory matches future observations

  18. Theory building in programming while (true) { pick up new requirement; if (surprise) {refactor theory}; } Refactor theory program output past future

  19. Theory building in programming Over time, tune program to satisfy requirements ● Goal: avoid “dead ends”, program can always be adapted to next requirement ● Refactor theory program output past future How well I understand ≈ How well program can produce future output

  20. What makes a theory valuable? Worse understanding Better understanding

  21. DDD breakthrough Eric Evans, Domain Driven Design, 2004

  22. [P]rogramming properly should be Peter Naur (1985) regarded as an activity by which the programmers form or achieve a Programming as certain kind of insight, a theory, of the Theory Building matters at hand. This suggestion is in contrast to what appears to be a more common notion, that programming should be regarded as a production of a program and certain other texts.

  23. Programming without theory building Every feature we add to [P]rogramming should be this geocentric model regarded as a production makes it harder to add of a program and certain the next feature! other texts.

  24. Example behavior with/without models Without models With models 1. Get new requirement 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 2. Write test case 4. Write test case 3. Edit code minimally so test passes 5. Revise code to match model 4. Refactor to remove code duplication

  25. Building theories!

  26. Programming is distributed cognition

  27. Long division ????? ------- 45 | 13095

  28. Long division 2?? ------- 45 | 13095 90 -- 40

  29. Long division 29? ------- 45 | 13095 90 -- 409 405 --- 4

  30. Long division 291 ------- 45 | 13095 90 -- 409 405 --- 45 45 With scribbles on paper, we can solve problems that don’t fit in our heads

  31. Internal-external representations match ????? ------- 45 | 13095 But not just any scribbles

  32. Roman numerals, really? ??????? --------- XLV | XIIIXCV

  33. Arabic numerals, unhelpful positions 4 3 5 1 0 9 5

  34. Internal - external model alignment Diagram from Stroop effect, not long division

  35. Distributed cognition Limits to pure-internal cognition So we use internal + external ● [D]ifferent representations of a problem can have dramatic impact on problem difficulty even if the formal structures are the same. -- Jaijie Zhang and Donald Norman 1994

  36. How do you steer a ship?

  37. How do you steer a ship? Challenge 1: Team Many people, each with partial ● understanding Challenge 2: Internal-external Make internal sense of external ● representation (charts, logs, …) Success requires: Compatible models across team ● Effective external representations ●

  38. Teamwork + external representation 291 ------- Diane Ann 45 | 13095 90 -- Bob 409 405 --- 45 Carl 45

  39. Programming: External representation Programming bridges internal and external representations Clues in the code Variable name “customers”, not “x” ● Named patterns ● Client-Server ○ Lambda ○ Observer ○ Note: these are trivial examples; models are deep

  40. Distributed cognition: summary ● Can solve bigger problems with a pencil ● … but only if models align between paper and head ● Teams must share models ● … and their external representation ● We express our models in source code ● … for us, for our team

  41. Distributed cognition! (as a team)

  42. Where are we? ● Gut feel that models are helpful ● Learned about theory building ○ Parallels between science and programming ● Learned about distributed cognition ○ Can solve bigger problems with a pencil ○ … but only if models align between paper and head ● So … what are our models?

  43. What are our models?

  44. “von Neumann architecture”

  45. You, doing “architecture recovery” You are recognizing existing patterns / models “Hey, it looks like your system, broadly speaking, has 3 tiers …” ● “Is it reasonable to group these 3 boxes as related to batch processing?” ● “Can you point out which boxes have persistent state, which are stateless?” ● Reusable models must be linked (Sitting in a book they do nothing)

  46. Developers weave models into programs Compare: Novelist weaving a story ● Hero’s journey, character development, foreshadowing, dramatic irony, ○ tension/humor, … Programmer weaving a program ● Reusable and ad hoc domain models ○ Patterns and styles ○ Development processes and practices ○ Models are richer than we can yet describe ●

  47. Types of models visible in code Domain ● Industry standard ontologies Solution ● Patterns (idioms, design, architecture) ● “Programming styles” (Cristina Videira Lopes) ● Responsibility allocation, encapsulation, parsing Mathematical Logic ● Logic, set theory, category theory, metamodeling

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend