Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 5: MVC Architecture Chapter 5.

Similar presentations


Presentation on theme: "Chapter 5: MVC Architecture Chapter 5."— Presentation transcript:

1 Chapter 5: MVC Architecture Chapter 5

2 We will … Learn MVC software architecture
Describe MVC-based solution for ball shooting Examine Expendability of MVC solutions Develop software library support for MVC framework: UWBGL Chapter 5

3 In a nutshell … So far … This chapter: Programming model: event driven
GUI API: elements and event registrations Graphics API: GHC initialization and drawing with RC This chapter: MVC Architecture: consolidate all of the above! Chapter 5

4 The MVC Architecture Chapter 5

5 Model-View-Controller
Application state The persistent variables View Draws the application state Graphics API support Controller Accepts input from user to change the model GUI API support Chapter 5

6 Model of Ball shooting program
Chapter 5

7 Model: Application State: Support: All persistent variables
State Inquiries State Changes Timer event support (Simulation update) State Visualization Chapter 5

8 View of Ball shooting program
Chapter 5

9 Controller of Ball shooting program
ViewController: is our Camera! Chapter 5

10 Expanding Ball shooting program
Chapter 5

11 Implement 2 views … Chapter 5

12 Notes on MVC … Simplicity: Portability: Expendability:
Model: usually most complex MVC: allow design of Model to be independent from user interaction and from drawing Portability: E.g., Change of controller ports Model to a different GUI platform Expendability: As we have seen: adding new view/controller pairs is straightforward Chapter 5

13 MVC: component interactions
User change application state: Via controllers Application changes its own state Via timer events All controllers and views must present consistent state GUI element must be correct: e.g., slider bar reflecting the falling hero ball position Drawing must be update to date Classic MVC architecture Elaborate protocol to ensure all states are consistent … Chapter 5

14 MVC with real-time simulation …
Every 25 milliseconds: timer fires! Application state likely to change MUST redraw all views!! During Timer event … ALWAYS Poll/update all controllers Update Application state Update all views Simple update protocol Chapter 5

15 2-View ball shooting component interaction
Chapter 5

16 Inter-Ball Collision Chapter 5


Download ppt "Chapter 5: MVC Architecture Chapter 5."

Similar presentations


Ads by Google