Model-View-Controller Architecture CS 5010 Program Design Paradigms “Bootcamp” Lesson 12.5 © Mitchell Wand, 2012-2014 This work is licensed under a Creative.

Slides:



Advertisements
Similar presentations
Categories of I/O Devices
Advertisements

Basics of Inheritance CS 5010 Program Design Paradigms "Bootcamp" Lesson 12.1 © Mitchell Wand, This work is licensed under a Creative Commons.
Patterns of Interaction 2: Publish-Subscribe CS 5010 Program Design Paradigms "Bootcamp" Lesson 11.6 © Mitchell Wand, This work is licensed under.
Midterm Review CS 5010 Program Design Paradigms “Bootcamp” Lesson 9.4 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.:
Interfaces CS 5010 Program Design Paradigms "Bootcamp" Lesson 10.2 © Mitchell Wand, This work is licensed under a Creative Commons Attribution-NonCommercial.
Language Issues for Inheritance CS 5010 Program Design Paradigms "Bootcamp" Lesson 12.3 © Mitchell Wand, This work is licensed under a Creative.
OOP Design Patterns Chapters Design Patterns The main idea behind design patterns is to extract the high level interactions between objects and.
Object-Oriented Analysis and Design
Stanford hci group / cs376 research topics in human-computer interaction UI Software Tools Scott Klemmer 27 October 2005.
Classes, Objects, and Interfaces CS 5010 Program Design Paradigms "Bootcamp" Lesson 10.3 © Mitchell Wand, This work is licensed under a Creative.
8. INPUT, OUTPUT and storage DEVICES i/o units
Patterns of Communication Between Objects CS 5010 Program Design Paradigms "Bootcamp" Lesson 11.1 © Mitchell Wand, This work is licensed under.
Lecture 7: Objects and Interaction 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271 
Section 2.1 Identify hardware Describe processing components Compare and contrast input and output devices Compare and contrast storage devices Section.
Model View Controller (MVC) Rick Mercer with a wide variety of others 1.
Converting from Immutable to Mutable Objects CS 5010 Program Design Paradigms "Bootcamp" Lesson 11.4 © Mitchell Wand, This work is licensed under.
The Function Design Recipe CS 5010 Program Design Paradigms “Bootcamp” Lesson 1.1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete.
Examining Two Pieces of Data CS 5010 Program Design Paradigms “Bootcamp” Lesson © Mitchell Wand, This work is licensed under a Creative.
The Design Recipe using Classes CS 5010 Program Design Paradigms "Bootcamp" Lesson 10.5 © Mitchell Wand, This work is licensed under a Creative.
(c) University of Washington08-1 CSC 143 Models and Views Reading: Ch. 18.
The Point of This Course CS 5010 Program Design Paradigms “Bootcamp” Lesson 0.1 © Mitchell Wand, This work is licensed under a Creative Commons.
Using Inheritance to Share Implementations CS 5010 Program Design Paradigms "Bootcamp" Lesson 12.1 © Mitchell Wand, This work is licensed under.
3461 Model-View Controller Advanced GUI concepts.
Model View Controller (MVC) Bigger than a Pattern: It’s an Architecture Rick Mercer with help from many others 1.
Two Draggable Cats CS 5010 Program Design Paradigms “Bootcamp” Lesson TexPoint fonts used in EMF. Read the TexPoint manual before you delete this.
A Simple Introduction to Git: a distributed version-control system CS 5010 Program Design Paradigms “Bootcamp” Lesson 0.5 © Mitchell Wand, This.
Model View Controller (MVC) Bigger than a Pattern: It’s an Architecture Rick Mercer with help from many of others 1.
Model-View-Controller Architecture CS 5010 Program Design Paradigms “Bootcamp” Lesson © Mitchell Wand, This work is licensed under a Creative.
An operating system is the software that makes everything in the computer work together smoothly and efficiently. What is an Operating System?
A Case Study: Space Invaders CS 5010 Program Design Paradigms "Bootcamp" Lesson © Mitchell Wand, This work is licensed under a Creative.
Testing Objects CS 5010 Program Design Paradigms "Bootcamp" Lesson © Mitchell Wand, This work is licensed under a Creative Commons Attribution-NonCommercial.
Patterns of Interaction 2: Publish-Subscribe CS 5010 Program Design Paradigms "Bootcamp" Lesson © Mitchell Wand, This work is licensed.
The Design Recipe using Classes CS 5010 Program Design Paradigms "Bootcamp" Lesson © Mitchell Wand, This work is licensed under a Creative.
Chapter 1 09/04/13. Change Your Password  The command is: passwd In the lab first do : ssh -Y onyx  You will have to see me to change it, if you forget.
File Systems cs550 Operating Systems David Monismith.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4: Events Programming with Alice and Java First Edition by John Lewis.
Callbacks and Interacting Objects CS 5010 Program Design Paradigms "Bootcamp" Lesson © Mitchell Wand, This work is licensed under a Creative.
Generalizing this Design CS 5010 Program Design Paradigms "Bootcamp" Lesson © Mitchell Wand, This work is licensed under a Creative Commons.
Organization of This Course CS 5010 Program Design Paradigms “Bootcamp” Lesson 0.2 © Mitchell Wand, This work is licensed under a Creative Commons.
Interactive Programming Alice. Control of flow Control of flow -- how the sequence of actions in a program is controlled. What action happens first, what.
Model View Controller (MVC) an architecture Rick Mercer with help from many of others 1.
Stateful Objects and Stable Identities CS 5010 Program Design Paradigms "Bootcamp" Lesson © Mitchell Wand, This work is licensed under.
The Last Lecture CS 5010 Program Design Paradigms "Bootcamp" Lesson © Mitchell Wand, This work is licensed under a Creative Commons Attribution-NonCommercial.
Lecture Model View Controller s/w architecture AND general tips on structuring classes.
Observerables are not Fields CS 5010 Program Design Paradigms "Bootcamp" Lesson 10.7 © Mitchell Wand, This work is licensed under a Creative.
Midterm Review CS 5010 Program Design Paradigms “Bootcamp” Lesson TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.:
Converting from Immutable to Mutable Objects CS 5010 Program Design Paradigms "Bootcamp" Lesson © Mitchell Wand, This work is licensed.
12-Jun-16 Event loops. 2 Programming in prehistoric times Earliest programs were all “batch” processing There was no interaction with the user Input Output.
Model-View-Controller Architecture
A Simple Introduction to Git: a distributed version-control system
Event loops 16-Jun-18.
MVC and Design Patterns
CS 5010 Program Design Paradigms “Bootcamp” Lesson 8.7
CS 5010 Program Design Paradigms "Bootcamp" Lesson 12.1
Callbacks and Interacting Objects
CS 5010 Program Design Paradigms “Bootcamp” Lesson 3.4
Patterns of Interaction 2: Publish-Subscribe
Patterns of Interaction 2: Publish-Subscribe
Event loops.
Assignment 4 For this assignment refer to the notes on MATLAB from an MIT course that you can find here (or at the original website, lectures 14, 15, 16).
Event loops 17-Jan-19.
Event loops 17-Jan-19.
Event loops 8-Apr-19.
Event loops.
CS 5010 Program Design Paradigms "Bootcamp" Lesson 12.1
Examining Two Pieces of Data
Event loops.
Event loops 19-Aug-19.
CS 5010 Program Design Paradigms “Bootcamp” Lesson 3.4
Presentation transcript:

Model-View-Controller Architecture CS 5010 Program Design Paradigms “Bootcamp” Lesson 12.5 © Mitchell Wand, This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License. Creative Commons Attribution-NonCommercial 4.0 International License 1

Special Bonus Lecture This is a lecture on the Model-View-Controller architecture, which is widely used for GUI, instrumentation, and other applications. It hasn’t been part of the course since Spring 2012, but I thought I’d put it up here for anybody who wanted to study it. This lecture is offered without any guarantees or warranties. But please feel free to ask questions about it on Piazza. 2

In general, our simulations have 3 parts A Model (something being simulated) A View (a way to display some of the information in model) A Controller (a way to provide inputs to the model, often based on the view) 3

Helpful to separate these Each part may be complicated (separation of concerns) Model shouldn't care about how it is displayed May have several viewers and controllers Model and viewer may be running at different rates Clarify interface between controller and model. 4

Example: multiple viewers Imagine: some temperature is being monitored/modelled/controlled Multiple viewers: – display in Celsius – display in Fahrenheit – display on a slider May want to change/add viewers dynamically 5

Example: Flight simulator Model: at each instant, calculates new state of the airplane (airspeed, altitude, attitude, etc., based on current airspeed, etc., and position of control surfaces View #1: digital airspeed indicator View #2: analog (dial) airspeed indicator Controller #1: pilot controls (arrow keys) Controller #2: copilot controls (mouse) 6

Flight Simulator (cont'd) Controllers send messages to model Model publishes changes in airspeed, displays subscribe So model doesn't need to know about controllers or views ! 7

Our current architecture has these all mixed together Every WorldObj or StatefulWorldObj is responsible for all 3 aspects: – on-tick (Model) – add-to-scene (View) – on-mouse, on-key (Controller). What can we do about this? 8

Instead: MVC architecture Divide a simulation into: – Model: the part that actually simulates the system in question – View: the part that displays the state of the system – Controller: the part that takes user input and transmits it to the model [Demo: run 13-mvc/top.rkt in the examples file.] 9

Views and Controllers are often tightly linked In our examples, Views and Controllers are tightly linked – mouse input is interpreted relative to screen position & the viewer that's running at that screen position. So we'll treat them together and call them controllers. Note: with other input devices, controllers and viewers may be entirely separate: – E.g. a flight simulator with a joystick 10

Model and Controller are weakly linked Each controller is linked to a single model A model may be linked to many controllers Model publishes changes in its state to the subscribed controllers. Each controller responds to its mouse and keyboard inputs by sending commands to the model. Model may change its state in response to commands it receives 11

Model Controller One model, many controllers model publishes changes controllers listen for changes 12

Model Controller MVC Feedback loop controller receives changes controller receives input from mouse, keyboard, etc model publishes changes controller sends commands to model model responds to commands, maybe changing its state 13

MVC Feedback Loop Controller receives changes Controller receives external stimuli Controller sends commands to model Model responds to commands Model publishes changes 14

Let's look at some code... In 13-mvc, look at the files in the following order: – interfaces.rkt – timer.rkt – slider.rkt – world.rkt – top.rkt – display.rkt 15