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 viewswill 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