Presentation is loading. Please wait.

Presentation is loading. Please wait.

Models and Reality: Master Program Execution with DCI

Similar presentations


Presentation on theme: "Models and Reality: Master Program Execution with DCI"— Presentation transcript:

1 Models and Reality: Master Program Execution with DCI
UML China 2010 19-Sep-18 Models and Reality: Master Program Execution with DCI UML China 2010 Trygve Reenskaug Dept. of Informatics University of Oslo heim.ifi.uio.no/~trygver/themes/babyide ©2010 Trygve Reenskaug UML-China 2010 :30

2 Two commonly believed Fallacies
UML China 2010 Two commonly believed Fallacies 19-Sep-18 End users cannot understand modern programs FALSE BECAUSE: Object Models are understandable BUT: Code must implement user mental model Programmers cannot read modern programs FALSE BECAUSE: Object systems can be coded to be readable and checkable BUT: Code must describe program runtime structure ©2010 Trygve Reenskaug UML-China 2010 :30

3 Reality program execution creates value
UML China 2010 Reality program execution creates value 19-Sep-18 IDE Personal plans Project control Calender Accounting ©2010 Trygve Reenskaug UML-China 2010 :30

4 End User System Experience
UML China 2010 End User System Experience 19-Sep-18 End User mental model domain model (what the system IS) use cases (what the system DOES) Runtime (objects and interactions) Chasm Compile time (classes, superclasses) class model code Programmer mental model ©2010 Trygve Reenskaug UML-China 2010 :30

5 Plan The User’s mental model Object Orientation CRC Cards
UML China 2010 Plan 19-Sep-18 The User’s mental model Object Orientation CRC Cards Lean and Agile The Programmer’s mental model Defect removal Conclusion ©2010 Trygve Reenskaug UML-China 2010 :30

6 Object-Orientation: networks of communicating objects
UML China 2010 Object-Orientation: networks of communicating objects 19-Sep-18 Alan Kay: Each Smalltalk object is a recursion on the entire possibilities of the computer. Thus its semantics are a bit like having thousands and thousands of computers all hooked together by a very fast network The essence of object orientation is the interchange of messages that takes place in the space between the objects ©2010 Trygve Reenskaug UML-China 2010 :30

7 True Object Orientation Objects as participants in commnication
UML China 2010 True Object Orientation Objects as participants in commnication 19-Sep-18 receive methods memory receive methods memory receive methods memory ©2010 Trygve Reenskaug UML-China 2010 :30

8 End User performs a Money Transfer What the System DOES
UML China 2010 End User performs a Money Transfer What the System DOES 19-Sep-18 ©2010 Trygve Reenskaug UML-China 2010 :30

9 End User’s Mental Model What the system DOES
UML China 2010 End User’s Mental Model What the system DOES 19-Sep-18 Customer Bank FromAccount ToAccount transfer ( amount, fromAccount, toAccount) transfer (...) deposit (...) ©2010 Trygve Reenskaug UML-China 2010 :30

10 Three Use Case Executions Money Transfers
UML China 2010 Three Use Case Executions Money Transfers 19-Sep-18 use case execution use case execution use case execution Class ATM Class SavingsAccount Class CheckingAccount ©2010 Trygve Reenskaug UML-China 2010 :30

11 Name the objects by the roles they play in the Interaction
UML China 2010 Name the objects by the roles they play in the Interaction 19-Sep-18 662454 136585 748534 995124 254967 245872 554782 221483 ID use case executions ATM SavingsAccount CheckingAccount --- Class Bank FromAccount ToAccount Bank FromAccount --- Role ©2010 Trygve Reenskaug UML-China 2010 :30

12 CRC Class – Responsibility – Collaboration
UML China 2010 CRC Class – Responsibility – Collaboration 19-Sep-18 Wikipedia: Sloppy thinking CRC cards are usually created from index cards on which are written: The class name Its Super and Sub classes (if applicable) The responsibilities of the class. The names of other classes with which the class will collaborate to fulfill its responsibilities. Author ©2010 Trygve Reenskaug UML-China 2010 :30

13 CRC Candidate – Responsibility – Collaboration
UML China 2010 CRC Candidate – Responsibility – Collaboration 19-Sep-18 CRC cards are usually created from index cards on which are written: The role name. The responsibilities of the roles (and the objects that play them). The names of other roles with which the role will collaborate to fulfill its responsibilities. Author. Candidate role – Responsibility -- Collaboration Wirfs-Brock; McKean: Object Design. Roles, Responsibilities, and Collaborations ©2010 Trygve Reenskaug UML-China 2010 :30

14 role name = FromAccount
UML China 2010 CRC Cards Example 19-Sep-18 role name = Bank responsibility = To serve the customer with a transfer of funds collaborators = FromAccount role name = FromAccount responsibility = To transfer funds from this account to its collaborator collaborators = ToAccount role name = ToAccount responsibility = To receive funds as part of a funds transfer collaborators = none ©2010 Trygve Reenskaug UML-China 2010 :30

15 Summary Object Models are understandable
UML China 2010 19-Sep-18 End user mental model explains how the system works. End user mental model is an object model: Objects Can store data Can handle received messages Can send messages to other objects Objects interact to to achieve a use case Objects are named by the role they play in the interaction ©2010 Trygve Reenskaug UML-China 2010 :30

16 Coplien, Bjørnvig: Lean Architecture ISBN: 978-0-470-68420-7
UML China 2010 Coplien, Bjørnvig: Lean Architecture ISBN: 19-Sep-18 Building Software as if people mattered No waste Get it right the first time! Be prepared for changes! Lean Principle: ”everybody, all together, from early on.” System architecture shall reflect the end user's mental model. Architecture has two parts: What the system IS: Its state What the system DOES: Its behavior Architecture a skeleton program ©2010 Trygve Reenskaug UML-China 2010 :30

17 Plan The Programmer’s mental model The Chasm betweenCode and Execution
UML China 2010 Plan 19-Sep-18 The User’s mental model Object Orientation CRC Cards Lean and Agile The Programmer’s mental model The Chasm betweenCode and Execution What the system IS – What the system DOES Separation of concerns: Contexts with Roles DCI: Data – Context – Interaction Defect removal Conclusion ©2010 Trygve Reenskaug UML-China 2010 :30

18 Gamma, Helm, Johnson, Vlissides: Design Patterns
UML China 2010 Gamma, Helm, Johnson, Vlissides: Design Patterns 19-Sep-18 An object-oriented program's run-time structure often bears little resemblance to its code structure. The code structure is frozen at compile-time; it consists of classes in fixed inheritance relationships. The run-time structure consists of rapidly changing networks of communicating objects. It's clear that code won't reveal everything about how a system will work. [GOF p.22, 23] ©2010 Trygve Reenskaug UML-China 2010 :30

19 The Essence of Object Orientation
UML China 2010 The Essence of Object Orientation 19-Sep-18 a class reveals everything about how an instance will handle an incoming message and reveals nothing about its collaborator or why the message was sent. an object by itself is not interesting the essence of object orientation is that objects communicate to achieve a common goal We need explicit code that clearly specifies the Contexts, i.e., the networks of communicating roles ©2010 Trygve Reenskaug UML-China 2010 :30

20 Class Hierachy is Irrelevant for program execution
UML China 2010 Class Hierachy is Irrelevant for program execution 19-Sep-18 Object Wikipedia: Code refactoring is the process of changing a computer program's source code without modifying its external functional behavior. copy Shape center area F_Circle F_Polygon Circle Polygon copy center area radius copy center area vertices radius vertices ©2010 Trygve Reenskaug UML-China 2010 :30

21 The Chasm between End User and Programmer
UML China 2010 The Chasm between End User and Programmer 19-Sep-18 End User mental model domain model (what the system IS) use cases (what the system DOES) Runtime (objects and interactions) Chasm Compile time (classes, superclasses) class model code Programmer mental model ©2010 Trygve Reenskaug UML-China 2010 :30

22 Use Case Context and Roles
UML China 2010 Use Case Context and Roles 19-Sep-18 BankTransferContext Environment role Bank role ToAccount transfer ( amount, fromAccount, toAccount) role FromAccount transfer (..) deposit (..) Customer role methods ©2010 Trygve Reenskaug UML-China 2010 :30

23 Each Use Case Is Executed in a Context
UML China 2010 Each Use Case Is Executed in a Context 19-Sep-18 Context-2 Use case-2 Context-1 Use case-1 Use case-3 Context-3 Role binding +Role Method injection ©2010 Trygve Reenskaug UML-China 2010 :30

24 Three Perspectives Data – Context - Interaction
UML China 2010 Three Perspectives Data – Context - Interaction 19-Sep-18 Compile time Data, Context, Interaction Object model code Data – What-The-System-IS Implementation of user’s domain model Dumb, dumb classes and superclasses without interaction code. Context – The Roles Participating in a Use Case Roles and role structure Select objects to play the roles. Inject role methods into selected objects (or their classes) Trigger Interaction. Interaction – What-The-System-DOES Role Methods direct the execution of the Use Case ©2010 Trygve Reenskaug UML-China 2010 :30

25 Programmer’s Mental Model Data Perspective
UML China 2010 Programmer’s Mental Model Data Perspective 19-Sep-18 End User domain model Conceptual schema «realize» Class attributes + local methods «instantiate classes to object» data objects ©2010 Trygve Reenskaug UML-China 2010 :30

26 Programmer’s Mental Model Context Perspective
UML China 2010 Programmer’s Mental Model Context Perspective 19-Sep-18 End User use cases Environment use case Context Role Role Role Bind roles to objects data objects ©2010 Trygve Reenskaug UML-China 2010 :30

27 Programmer’s Mental Model Interaction Perspective
UML China 2010 Programmer’s Mental Model Interaction Perspective 19-Sep-18 Class definitions Context Role Method definitions package babydemo3.model; import babydemo3.model.Model; import babydemo3.model.collaboration.*; import babydemo3.model.algorithm.*; import babydemo3.model.data.*; import java.util.*; import java.awt.Color; public class Model extends Observable { private NetBase netBase; private Resource resource; public Model() {} public Resource resource() {} public void reset() {} public void addActivity(String name, Integer duration, Color color) {} public void addDependency(String predName, String succName) {} public void frontloadNetwork(Integer startWeek) { RoleB.frontload(startWeek); setChanged(); notifyObservers("ACTIVITY"); } RoleA>> public void frontloadNetwork(Integer startWeek) { RoleB.frontload(startWeek); setChanged(); notifyObservers("ACTIVITY"); } RoleB>>public void frontload(Integer startWeek) { // reset all for (Activity act : AllActivities) { act.setEarlyStart(null); } // frontload all Activity frontloader; while (CurrentContext.rebind(); Activity != null) { Integer earlyStart = startWeek; for (Activity pred : Predecessors) { earlyStart = Math.max(earlyStart, pred.earlyFinish() + 1); Activity.setEarlyStart(earlyStart); package babydemo3.model.algorithm; import babydemo3.model.Model; import babydemo3.model.data.Activity; import babydemo3.model.collaboration.FrontloadCollab; public class Case { private Plan model; } public void frontload(Integer startWeek) { // reset all for (Activity act : AllActivities) { act.setEarlyStart(null); } // frontload all Activity frontloader; while (CurrentContext.reselect(); Activity != null) { Integer earlyStart = startWeek; for (Activity pred : Predecessors) { earlyStart = Math.max(earlyStart, pred.earlyFinish() + 1); Activity.setEarlyStart(earlyStart); inject role methods ©2010 Trygve Reenskaug UML-China 2010 :30

28 Programmer’s Mental Model The Whole Story
UML China 2010 Programmer’s Mental Model The Whole Story 19-Sep-18 End User use cases domain model Conceptual schema Environment use case task realize Context Role Role Class attributes + local methods + role methods Inject role methods Role «instantiate classes to objects» «bind roles to objects» data objects interaction ©2010 Trygve Reenskaug UML-China 2010 :30

29 Plan Defect removal Lean: Get it right the first time
UML China 2010 Plan 19-Sep-18 The User’s mental model Object Orientation CRC Cards Lean and Agile The Programmer’s mental model The Chasm betweenCode and Execution What the system IS – What the system DOES Separation of concerns: Contexts with Roles DCI: Data – Context – Interaction Defect removal Lean: Get it right the first time Chunkable, readable code. BabyIDE. Software Peer Review Conclusion ©2010 Trygve Reenskaug UML-China 2010 :30

30 Edsger W. Dijkstra on Bugs
UML China 2010 Edsger W. Dijkstra on Bugs 19-Sep-18 "Program testing can be used to show the presence of bugs, but never to show their absence!“ "Simplicity is prerequisite for reliability.“ ©2010 Trygve Reenskaug UML-China 2010 :30

31 Peer Review Datamation Magazine ca. 1967
UML China 2010 Peer Review Datamation Magazine ca. 1967 19-Sep-18 It’s hard to find bugs in own code It’s fun to find bugs in other people’s code Coder learns from reviewer’s comments Reviewer learns by reading the code Wikipedia: savings exceeds costs by 4 to 1". Get it right the first time! Test to confirm no blunder! --- but execute all statements Code must be Chunkable! Readable! ©2010 Trygve Reenskaug UML-China 2010 :30

32 Code must be Chunkable! Readable!
UML China 2010 Code must be Chunkable! Readable! 19-Sep-18 DCI Separation Of Concerns: Data: Data classes greatly simplified; realize ’pure’ data model. Context: One Context for each use case, isolated from other Contexts. Interaction: Roles only meaningful within their Context Role to object binding done within one chunk of methods. The Role Methods specify system behavior ©2010 Trygve Reenskaug UML-China 2010 :30

33 BabyIDE DCI Integrated Development Environment
UML China 2010 BabyIDE DCI Integrated Development Environment 19-Sep-18 2 1 3 4 ©2010 Trygve Reenskaug UML-China 2010 :30

34 Plan Conclusion The User’s mental model Object Orientation CRC Cards
UML China 2010 Plan 19-Sep-18 The User’s mental model Object Orientation CRC Cards Lean and Agile The Programmer’s mental model The Chasm betweenCode and Execution What the system IS – What the system DOES Separation of concerns: Contexts with Roles DCI: Data – Context – Interaction Defect removal Lean: Get it right the first time Chunkable, readable code. BabyIDE. Software Peer Review Conclusion ©2010 Trygve Reenskaug UML-China 2010 :30

35 Conclusion – 1 of 4 DCI = Readable Code
UML China 2010 Conclusion – 1 of 4 DCI = Readable Code 19-Sep-18 The DCI paradigm: Work with program in different perspectives D ata Classes for what the system IS C ontext for the network of communicating roles I nteraction for what the system DOES ©2010 Trygve Reenskaug UML-China 2010 :30

36 Conclusion – 2 of 4 DCI = Changeable Code
UML China 2010 Conclusion – 2 of 4 DCI = Changeable Code 19-Sep-18 Data perspective compact; system state only. Role/object selection separates system state and system behavior. Existing Contexts can be changed independently. New Contexts can be added to realize new funtionality. ©2010 Trygve Reenskaug UML-China 2010 :30

37 Conclusion – 3 of 4 End User Mental Model = Code
UML China 2010 Conclusion – 3 of 4 End User Mental Model = Code 19-Sep-18 End User mental model domain model (what the system IS) use cases (what the system DOES) Runtime (objects play roles) instantiate data classes to objects context selects objects to play roles inject role methods Chasm Bridged! Compile time (Data, Context, Interaction) Object model code Programmer mental model ©2010 Trygve Reenskaug UML-China 2010 :30

38 Conclusion – 4 of 4 State of DCI
UML China 2010 Conclusion – 4 of 4 State of DCI 19-Sep-18 DCI Implementation examples in Smalltalk/Squeak, C++, Java, C#, Ruby, Scala, Python. Real applications in Java (Qi4j, Rickard Øberg). New DCI Programming Language being developed. BabyIDE Squeak Demo version available Basic technology is freely available for toolmakers For now: Read the “Lean Architecture” book Read Wikipedia article Never forget the end user of your code Never forget the reader of your code DCI Community at ©2010 Trygve Reenskaug UML-China 2010 :30

39 Comments? Questions? UML China 2010 19-Sep-18 ©2010 Trygve Reenskaug
:30

40 More reading UML China 2010 19-Sep-18
mailto: Coplien, J.O., Bjørnvig, G; Lean Architecture for Agile Software Development; Wiley, Chichester, UK, 2010; ISBN Reenskaug, T; Wold, P.;, Lehne, O. A.: Working With Objects; Manning, Greenwich, CT 06830;1996; ISBN ; (Prentice Hall ISBN ). This book is out of print. An early .pdf version kan be downloaded free from [web page] Important Web resources: Kay on object orientation: The DCI defining reference: A technical article: More online resources: Reenskaug, T.: Programming with Roles and Classes; the BabyUML Approach; Chapter in Klein, A.D.; Computer Software Engineering Research; Nova Science Publishers, New York, 2007; ISBN-13: ;pp.45-88; [web page] Reenskaug, T,: The BabyUML discipline of programming (where A Program = Data + Communication + Algorithms). SoSym 5,1 (April 2006). DOI: /s x. [web page] Wirfs-Brock, R.; McKean, A.; Object Design. Roles, Responsibilities, and Collaborations. ISBN 0‑201‑37943‑0; Addison-Wesley; Boston, MA, 2003. Andersen, E. P.; Conceptual Modeling of Objects. A Role Modeling Approach. D.Scient thesis, November 1997, University of Oslo. [web page] Gamma et.al. (GOF) Design Patterns; ISBN ; Addison-Wesley, Reading, MA ©2010 Trygve Reenskaug UML-China 2010 :30


Download ppt "Models and Reality: Master Program Execution with DCI"

Similar presentations


Ads by Google