Presentation is loading. Please wait.

Presentation is loading. Please wait.

Fundamentals of Programming I The Model/View/Controller Design Pattern

Similar presentations


Presentation on theme: "Fundamentals of Programming I The Model/View/Controller Design Pattern"— Presentation transcript:

1 Fundamentals of Programming I The Model/View/Controller Design Pattern
Computer Science 111 Fundamentals of Programming I The Model/View/Controller Design Pattern

2 TUI vs GUI Text-based I/O Direct manipulation Sequential process
Event-driven process

3 TUI vs GUI Text-based I/O Sequential process Direct manipulation
Event-driven process

4 The Model/View Pattern
Data Model View (User Interface) The data model consists of software components that manage a system’s data The view consists of software components that allow human users to view and interact with the data model The view can be a TUI or a GUI, on the same data model

5 Model/View Pattern Classes in the data model, such as WarGame, Player, Deck, and Card, manage the application’s data Classes in the view, such as WarGUI, EasyFrame, PhotoImage, Button, and Label, present the data to users

6 The Data Model for the War Game
Player 2 WarGame Deck 0..52 Card

7 The Data Model and the View (GUI)
Button Player 2 2 EasyFrame WarGUI WarGame displays 3 Label Deck 0..52 Card

8 The Data Model for the Craps Game
Die 2 CrapsGame

9 The Data Model and the View (GUI)
Button Die 2 2 EasyFrame GrapsGUI CrapsGame displays 3 Label

10 Model/View/Controller Pattern
GUI-based, event-driven programs can be further decomposed by gathering code to handle user interactions into a third component called the controller Displays data Manages data View Model Controller Responds to user events

11 The Controller In Python, the controller consists of the methods that respond to user events These methods are defined in the main view class, and are associated with the command attribute of the buttons Other types of widgets can have their own event-handling methods

12 Event-Driven Programming
Set up a window with its widgets Connect it to a data model Wait for users to press buttons, enter text, drag the mouse, etc. Respond to these events by running methods that update the data model and the view

13 A Banking System BankManager SavingsAccount ATM * Bank File storage

14 Data persistence Pages 319-321
For Wednesday Data persistence Pages


Download ppt "Fundamentals of Programming I The Model/View/Controller Design Pattern"

Similar presentations


Ads by Google