Model View Controller Development architecture. MVC Model: the classes encapsulating the...
-
Upload
wilfred-skinner -
Category
Documents
-
view
213 -
download
0
Transcript of Model View Controller Development architecture. MVC Model: the classes encapsulating the...
![Page 1: Model View Controller Development architecture. MVC Model: the classes encapsulating the functionality of your app View: what the user sees and interfaces.](https://reader035.fdocuments.net/reader035/viewer/2022080905/56649ccf5503460f9499a685/html5/thumbnails/1.jpg)
Model View Controller
Development architecture
![Page 2: Model View Controller Development architecture. MVC Model: the classes encapsulating the functionality of your app View: what the user sees and interfaces.](https://reader035.fdocuments.net/reader035/viewer/2022080905/56649ccf5503460f9499a685/html5/thumbnails/2.jpg)
MVC
• Model: the classes encapsulating the functionality of your app
• View: what the user sees and interfaces with
• Controller: middleman between view and model
![Page 3: Model View Controller Development architecture. MVC Model: the classes encapsulating the functionality of your app View: what the user sees and interfaces.](https://reader035.fdocuments.net/reader035/viewer/2022080905/56649ccf5503460f9499a685/html5/thumbnails/3.jpg)
MVC
Model does not talk to the View directly
• When the View changes (via an event from the user for example), the Controller can update the Model
• When the Model changes (via some computation, for example), the Controller can refresh the View
![Page 4: Model View Controller Development architecture. MVC Model: the classes encapsulating the functionality of your app View: what the user sees and interfaces.](https://reader035.fdocuments.net/reader035/viewer/2022080905/56649ccf5503460f9499a685/html5/thumbnails/4.jpg)
MVC – Why?
• Separate User Interface and functionality
• Clean design
• Easier to modify your project
• Easier to work as a group or team
• Easier to separate the expertise of people (coding, graphics, ..)
![Page 5: Model View Controller Development architecture. MVC Model: the classes encapsulating the functionality of your app View: what the user sees and interfaces.](https://reader035.fdocuments.net/reader035/viewer/2022080905/56649ccf5503460f9499a685/html5/thumbnails/5.jpg)
MVC – Tic Tac Toe
XX O
O
![Page 6: Model View Controller Development architecture. MVC Model: the classes encapsulating the functionality of your app View: what the user sees and interfaces.](https://reader035.fdocuments.net/reader035/viewer/2022080905/56649ccf5503460f9499a685/html5/thumbnails/6.jpg)
MVC – Tic Tac Toe
• What will be in the View?
• 9 buttons that the user will interact with
• Other things (labels) to tell the user what is going on (anybody won? ) and give some feedback (cannot play here, ..)
![Page 7: Model View Controller Development architecture. MVC Model: the classes encapsulating the functionality of your app View: what the user sees and interfaces.](https://reader035.fdocuments.net/reader035/viewer/2022080905/56649ccf5503460f9499a685/html5/thumbnails/7.jpg)
MVC – Tic Tac Toe
• What will be in the Model?
• i.e. how can we represent the Tic Tac Toe game in a class?
• Natural instance variable = 2-dim array of 3 rows and 3 columns
• Whose turn is it to play?
![Page 8: Model View Controller Development architecture. MVC Model: the classes encapsulating the functionality of your app View: what the user sees and interfaces.](https://reader035.fdocuments.net/reader035/viewer/2022080905/56649ccf5503460f9499a685/html5/thumbnails/8.jpg)
MVC – Tic Tac Toe
• What else will be in the Model?
• i.e. how can we represent playing Tic Tac Toe in a class?
• Functions to play, enforce the rules, update the 2-dim array, determine whose turn is it to play, if the game is over, if somebody won, ..
![Page 9: Model View Controller Development architecture. MVC Model: the classes encapsulating the functionality of your app View: what the user sees and interfaces.](https://reader035.fdocuments.net/reader035/viewer/2022080905/56649ccf5503460f9499a685/html5/thumbnails/9.jpg)
MVC – Tip calculator
• TipCalculator class
• Instance variables, init method, accessors, mutators, methods to calculate tip, tip per guest, total bill, ..