MVC COMP 401 Fall 2014 Lecture 19 10/30/2014. Classic MVC 2

Slides:



Advertisements
Similar presentations
Chapter 18 Building the user interface. This chapter discusses n Javas graphical user interface. n Swing: an enhancement of a library called the Abstract.
Advertisements

Introduction to Macromedia Director 8.5 – Lingo
Synchronization and Deadlocks
Pipelining and Control Hazards Oct
Basic Excel Information Summer Spreadsheet Basics When you open Excel, the file you have opened is a workbook. Each workbook contains three worksheets.
OOP Design Patterns Chapters Design Patterns The main idea behind design patterns is to extract the high level interactions between objects and.
Handling Money Cash Register Receipts. Patrons may pay for library fines, fees, lost books, guest accounts, merchandise, copy & print cards, and all other.
MVC Nick Lopez Duplication of course material for any commercial purpose without the explicit written permission of the professor is prohibited.
Computer Science 1620 Variables and Memory. Review Examples: write a program that calculates and displays the average of the numbers 45, 69, and 106.
Slides prepared by Rose Williams, Binghamton University Chapter 17 Swing I.
How to Debug VB .NET Code.
1 Binary Arithmetic, Subtraction The rules for binary arithmetic are: = 0, carry = = 1, carry = = 1, carry = = 0, carry =
EET 2261 Unit 2 HCS12 Architecture
Object-Oriented Analysis and Design
Introduction to C Programming
1 Binary Numbers Again Recall that N binary digits (N bits) can represent unsigned integers from 0 to 2 N bits = 0 to 15 8 bits = 0 to bits.
XHTML Forms for Data Collection and Submission Chapter 5.
 A data processing system is a combination of machines and people that for a set of inputs produces a defined set of outputs. The inputs and outputs.
Microsoft Visual Basic 2008 CHAPTER ELEVEN Multiple Classes and Inheritance.
The von Neumann Model – Chapter 4 COMP 2620 Dr. James Money COMP
Input/Output  Input/Output operations are performed using input/output functions  Common input/output functions are provided as part of C’s standard.
REQUIREMENTS CAPTURE 1 ASU Course Registration System User Interface Specifification UI Elements Register for courses Use Case.
Standard Form.
Digital Logic Design Lecture # 7 University of Tehran.
Model View Controller (MVC) Rick Mercer with a wide variety of others 1.
Welcome to CIS 083 ! Events CIS 068.
Microsoft Visual Basic 2008 CHAPTER ELEVEN Multiple Classes and Inheritance.
Java Software Solutions Lewis and Loftus Chapter 10 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphical User Interfaces --
Using the Web-Based Training Tool MyFloridaMarketPlace.
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
Slides prepared by Rose Williams, Binghamton University ICS201 Lecture 13 : Swing I King Fahd University of Petroleum & Minerals College of Computer Science.
Chapter 3: Formatted Input/Output Copyright © 2008 W. W. Norton & Company. All rights reserved. 1 Chapter 3 Formatted Input/Output.
Basic Program Construction
1 Kyung Hee University Diagram Editor : Design View Spring 2001.
Created by, Tom Rebold, MPC FLUENCY WITH INFORMATION TECNOLOGY Skills, Concepts, and Capabilities.
Model View Controller MVC Web Software Architecture.
Copyright © Lynda Greene Aguirre Exponential Form is used when you want to multiply the same number by itself several times. 5 is the base 4 is.
Lecture 5 1.What is a variable 2.What types of information are stored in a variable 3.Getting user input from the keyboard 1.
Microsoft Visual Basic 2012 CHAPTER ELEVEN Multiple Classes and Inheritance.
Programming Fundamentals. Overview of Previous Lecture Phases of C++ Environment Program statement Vs Preprocessor directive Whitespaces Comments.
CS1Q Computer Systems Lecture 2 Simon Gay. Lecture 2CS1Q Computer Systems - Simon Gay2 Binary Numbers We’ll look at some details of the representation.
Programming Fundamentals. Summary of previous lectures Programming Language Phases of C++ Environment Variables and Data Types.
Adding and Subtracting Decimals © Math As A Second Language All Rights Reserved next #8 Taking the Fear out of Math 8.25 – 3.5.
Introduction to Computer Programming - Project 2 Intro to Digital Technology.
 2007 Pearson Education, Inc. All rights reserved. A Simple C Program 1 /* ************************************************* *** Program: hello_world.
Observer / Observable COMP 401 Fall 2014 Lecture 14 10/7/2014.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 6: Restaurant.
Chapter 3: Formatted Input/Output 1 Chapter 3 Formatted Input/Output.
High degree of user interaction Interactive Systems: Model View Controller Presentation-abstraction-control.
Event-driven programming
Android 11: The Calculator Assignment
Multiple Classes and Inheritance
Observer Design Pattern
Lesson 1: Buttons and Events – 12/18
Introduction to Events
Chap 7. Building Java Graphical User Interfaces
Stack Data Structure, Reverse Polish Notation, Homework 7
Input/Output Input/Output operations are performed using input/output functions Common input/output functions are provided as part of C’s standard input/output.
Conditions and Ifs BIS1523 – Lecture 8.
INPUT & OUTPUT scanf & printf.
In Class Program: Today in History
MIPS ALU.
Week 6: Time and triggers!
ECE 352 Digital System Fundamentals
ECE 352 Digital System Fundamentals
Tonga Institute of Higher Education
Properties and Collections
ACM programming contest
Presentation transcript:

MVC COMP 401 Fall 2014 Lecture 19 10/30/2014

Classic MVC 2

Alternate MVC 3

MVC Calculator Design Start with the model. What does the model need to encapsulate?

lec19.v01 CalculatorModel – Encapsulates a history (i.e., a sequence) of operations. – A current value on which the next operation will occur. – Observable Notifies observers when model changes which in this case is whenever a new operation occurs. Operation – Specifies an operation Notice it doesn’t specify the value that the operation applied to or the result. – Why doesn’t that matter?

MVC Calculator Design Now design the view lec19.v02

Controller Controller sits between model and view – Responds to what happens in the view In our case: button pushes – Instructs view to change when necessary In our case: what is in the display, what is on the tape – Manipulates the model Registers operations to affect the value – Responds to model changes Causes registered operations to appear on the tape

Controller We need a way for controller to register itself with all of the view’s buttons. – lec19.v03 – Notice that controller encapsulates references to model and view. Model and view, however, don’t know about each other or the controller.

Handling Digits What should happen when a digit is pressed? – Depends on what has happened before. If we are starting a new number, we should replace the display with this digit. If we have already started a number, we should append the digit to the number already in the display. – Keeping track of this kind of logic and doing the right this is exactly the job of the controller. Things we need to add: – A way for the controller to get/set the display – A field in controller to keep track of whether we are starting a new number or not and corresponding logic – lec19.v04

Handling Decimal Point Should only allow one decimal point so needs to check to see if one is already there. Special case for beginning of number What we need: – Indicator of whether or not decimal point has already been pressed. – Logic to handle the button – lec19.v05

Handling Operations What happens when an operator is pressed? – The operator indicates which operation is now in progress. But we can’t actually do the operation until another number is entered. If an operation was already in progress, that operation should now complete using number in the display Things we need to add: – Field in controller to keep track of operation in progress. – Logic to apply operator in progress to model at the right time. Right time = when operand is complete and next operator is known. To get operand, we need to add method in view object to retrieve current display. – lec19.v06

Seeing the Output Controller now handling most buttons and sending operations to model – Need to react to changes in the model What we need: – Implement observer – Attach to model – Handle observed changes to model. – lec19.v07

Four Bugs and An Inversion Delay in seeing result when pressing = – No need to wait for next number when = is current operation Tape doesn’t scroll – Just need to put it in a ScrollPane Can’t change mind about operation – Shouldn’t do operation if at start of number Can’t make a zero – Logic for starting a number incorrect – Need to separate case of starting a number from the case that the number started is zero Still need to handle +/- – Interacts with number is zero – Need to watch out for fact that first character of this button is same as addition operation. lec19.v08

Reconsidering Design Things work (for the most part) But something is wrong with our design… – … think about what we would need to do in order to support keyboard numbers. – … think about what we would need to do in order to support buttons with image-based icons Current interaction between controller and view requires controller to know about view internals. – Instead of exposing raw underlying UI events, we should translate them into something more abstraction-specific. – lec19.v09 And now we can add keyboard input – lec19.v10