CompSci 100E8.1MVC: Model, View, Controllerÿ A model is the state and brains of a system In a game it's all the pieces and where they are In a spreadsheet it's the data and the formulaeÿ The view is how we look at the model Spread sheet has graphs, charts, cells, text, … Game has board, number of opponents, hit-points, …ÿ When the model changes, the views reflect the changes The model tells the views how/if it has changed Model sends information to views OR View asks model for informationCompSci 100E8.2MVC: interfaces and inheritanceÿ A model might have multiple views Tell all the views "I've changed" Who manages the views? This requires state: store views Why can't we keep this state in an interface?ÿ See IModel and AbstractModel One specifies behavior, the other provides default Don’t rewrite code if we don't have to, maintaining views will be the same for all modelsÿ See IView and SimpleView No default/shared view state/behavior: text and GUICompSci 100E8.3Does SimpleViewer know Model?ÿ What does the SimpleViewer know about its model? If we look at code, is there any application-specific logic? What if we wanted to play a game, start a new game?ÿ Control in MVC with SimpleViewer and IModel Loading a file calls initialize() Entering text calls process() Model calls view with messages, errors, and complete updateÿ This isn't complete general, but it's pretty generic For this input, here's the outputCompSci 100E8.4Pixmap Assignmentÿ “Last” CompSci 6 Assignment Lots has been done for you Mainly an exercise in working with 2 D info ÿ Not really MVC Doesn’t hurt to keep that model in mind, thoughÿ Lots of GUI stuff Graphical User Interface is not reall focus of this course Just use what has been given Become familiar with it by reading code, seeing resultsÿ Feel free to experimentCompSci 100E8.5Java Exceptionsÿ Many I/O operations can throw Exceptions Code handles it for your However, need to know what is going on (Review pages in Chapter 2)ÿ Catching Exceptions Use try-catch blocktry {// statements that might generate exception}catch (exception_type var){// code that deals with exception}ÿ Method can pass on responsibility for exception with
View Full Document