Section 8: Model-View-Controller

Slides:



Advertisements
Similar presentations
Apache Struts Technology
Advertisements

Library Online Catalog Tutorial Pentagon Library Last Updated March 2008.
1 Model View Controller. 2 Outline Review Definitions of MVC Why do we need it? Administiriva Changing the display Event flow Dragging at interactive.
Graphical User Interface (GUI) Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
Graphical User Interface (GUI) Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Object-Oriented Analysis and Design
Stanford hci group / cs376 research topics in human-computer interaction UI Software Tools Scott Klemmer 27 October 2005.
Slides by Alex Mariakakis with material from Krysta Yousoufian and Kellen Donohue Section 8: Model-View-Controller.
A physicist, an engineer and a programmer were in a car driving over a steep alpine pass when the brakes failed. The car was getting faster and faster,
MVC pattern and implementation in java
Moodle (Course Management Systems). Assignments 1 Assignments are a refreshingly simple method for collecting student work. They are a simple and flexible.
Event Driven Programming
TVAC Electronic Call Sheet System Team HeatWave Summer 2007.
FireRMS NEMSIS (Part 2) Presented by Laura Small FireRMS Quality Assurance.
JSF Introduction Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission.
AUTOMATION OF WEB-FORM CREATION - KINNERA ANGADI – MS FINAL DEFENSE GUIDANCE BY – DR. DANIEL ANDRESEN.
Slides adapted from Alex Mariakakis, with material from Krysta Yousoufian and Kellen Donohue Section 8: Model-View-Controller.
Access Forms and Queries. Entering Data in Your Table  You can add data to your table in Datasheet view, by typing in the columns and rows.  This.
G063 - Human Computer Interface Design Designing the User Interface.
Design Patterns -- Omkar. Introduction  When do we use design patterns  Uses of design patterns  Classification of design patterns  Creational design.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Chapter 5 Introduction To Form Builder. Lesson C Objectives  Use sequences to automatically generate primary key values in a form  Create lists of values.
Metric Studio Cognos 8 BI. Objectives  In this module, we will examine:  Concepts and Overview  An Introduction to Metric Studio  Cognos 8 BI Integration.
Slides with material from Alex Mariakakis, Krysta Yousoufian, Mike Ernst, Kellen Donohue Section 3: HW4, ADTs, and more.
1 © 2014 Atego. All Rights Reserved. Infrastructure Bridge Model Matthew Hause – Atego Chief Consulting Engineer
Go to enquos.com & click Register to register for your enquos account enquos.com Enter your activation code here.
Development Environment
“New” things Discussed in London
Essentials of UrbanCode Deploy v6.1 QQ147
OVERVIEW S9k Self-Assessment System
The Simulation of Traffic Patterns and Optimizing Traffic Lights
Microsoft Access 2013 Bobby Wan.
Day 1 on Google Cloud Platform
FOP: Buttons and Events
Section 8: Model-View-Controller
Due Dec 9th simple CHAT with
BASIC INFORMATION ABOUT DATABASE MANAGEMENT SOFTWARE
Introduction to Triggers
Observer Design Pattern
MVC and other n-tier Architectures
Web Programming– UFCFB Lecture 17
Lesson 1: Buttons and Events – 12/18
Introduction to Events
A physicist, an engineer and a programmer were in a car driving over a steep alpine pass when the brakes failed. The car was getting faster and faster,
Event Driven Programming
Chapter 12: Automated data collection methods
Chapter 2 Database Environment Pearson Education © 2009.
eTapestry Workshop Session 3: Queries and Reports
Model-View-Controller Patterns and Frameworks
Lecture 1: Multi-tier Architecture Overview
Near Real Time ETLs with Azure Serverless Architecture
Patterns.
Event Driven Programming
Professor John Canny Spring 2004 March 5
“New” things Discussed in London
Developing Listening strategies
Introduction to Access
A physicist, an engineer and a programmer were in a car driving over a steep alpine pass when the brakes failed. Their car raced down the mountain, and.
Section 4: Graphs and Testing
ECE 352 Digital System Fundamentals
!Sell Basics: How to use the system
Download the APhA 2018 app Scan the QR code or search for APhA in iTunes or APhA Annual in the Google Play store. For all other device types (including.
Model, View, Controller design pattern
MECH 3550 : Simulation & Visualization
PCW-09 Vision: Information Center Approval System
Event loops.
Professor John Canny Spring 2003 March 12
Chapter 2 Database Environment Pearson Education © 2009.
Server & Tools Business
“New” things Discussed in London
Presentation transcript:

Section 8: Model-View-Controller Slides adapted from Alex Mariakakis with material from Krysta Yousoufian, Kellen Donohue, and James Fogarty

Homework tips You must include the @SuppressWarnings("nullness") tags so that your code will build during grading Run ant validate on attu before submitting HW7 requires you to modify your code from HW5 and HW6 Make sure to address any issues you had that caused you to fail HW5 or HW6 staff tests

MVC The classic design pattern Used for data-driven user applications Such apps juggle several tasks: Loading and storing the data – getting it in/out of storage on request Constructing the user interface – what the user sees Interpreting user actions – deciding whether to modify the UI or data These tasks are largely independent of each other Model, view, and controller each get one task

Model talks to data source to retrieve and store data Which database table is the requested data stored in? talks to data source to retrieve and store data What SQL query will get me the data I need?

View asks model for data and presents it in a user-friendly format Would this text look better blue or red? In the bottom corner or front and center? asks model for data and presents it in a user-friendly format Should these items go in a dropdown list or radio buttons?

Controller listens for the user to change data or state in the UI, notifying the model or view accordingly The user just clicked the “hide details” button. I better tell the view. The user just changed the event details. I better let the model know to update the data.

Benefits of MVC Organization of code Ease of development Flexibility Maintainable, easy to find what you need Ease of development Build and test components independently Flexibility Swap out views for different presentations of the same data (ex: calendar daily, weekly, or monthly view) Swap out models to change data storage without affecting user

MVC Flow in Theory View Model Controller

MVC Flow In theory… Many architectures combine the two In practice… Pattern of behavior in response to inputs (controller) are independent of visual geometry (view) Controller contacts view to interpret what input events should mean in the context of the view In practice… View and controller are so intertwined that they almost always occur in matched pairs (ex: command line interface) Many architectures combine the two

MVC Flow in Practice View Model Controller

Homeworks HW8 – fine to keep view and controller together HW9 – separate the view and controller

Push vs. Pull View Model Controller

Push vs. Pull Architecture Push architecture As soon as the model changes, it notifies all of the views Pull architecture When a view needs to be updated, it asks the model for new data

Push vs. Pull Architecture

Push vs. Pull Architecture Advantages for push Guaranteed to have latest data in case something goes wrong later on Advantages for pull Avoid unnecessary updates, not nearly as intensive on the view

MVC Example – Traffic Signal

Traffic Signal – MVC Component Model View Controller Detect cars waiting to enter intersection Traffic lights to direct car traffic Regulate valid traffic movements Manual override for particular lights Detect pedestrians waiting to cross Pedestrian signals to direct pedestrians External timer which triggers changes at set interval X X X X X X X

Traffic Signal Stores current state of traffic flow Model Stores current state of traffic flow Knows current direction of traffic Capable of skipping a light cycle Stores whether there are cars and/or pedestrians waiting View Conveys information to cars and pedestrians in a specific direction Controller Aware of model’s current direction Triggers methods to notify model that state should change

Traffic Signal Code Model TrafficModel – keeps track of which lights should be on and off View CarLight – shows relevant state of TrafficModel to cars PedestrianLight – shows relevant state of TrafficModel to pedestrians Controller PedestrianButton – notifies TrafficModel that there is a pedestrian waiting CarDetector – notifies TrafficModel that there is a car waiting LightSwitch – enables or disables the light Timer – regulates time in some way, possibly to skip cycles

HW8 Overview Apply your generic graph & Dijkstra’s to campus map data Given a list of buildings and walking paths Produce routes from one building to another on the walking paths

HW8 Data Format List of buildings (abbreviation, name, loc in pixels) BAG Bagley Hall (East Entrance) 1914.5103,1708.8816 BGR By George 1671.5499,1258.4333 List of paths (endpoint 1, endpoint 2, dist in feet) 1903.7201,1952.4322 1906.1864,1939.0633: 26.583482327919597 1897.9472,1960.0194: 20.597253035175832 1915.7143,1956.5: 26.68364745009741 2337.0143,806.8278 2346.3446,817.55768: 29.685363221542797 2321.6193,788.16714: 49.5110360968527 2316.4876,813.59229: 44.65826043418031 (0,0) is in the upper left

MVC in HW8 Model stores graph, performs Dijkstra’s View shows results to users in text format Controller takes user commands and uses view to show results View and Controller will change in HW9, but Model will stay the same