Presentation on theme: "Model View Controller Development architecture. MVC Model: the classes encapsulating the functionality of your app View: what the user sees and interfaces."— Presentation transcript:
MVC Model: the classes encapsulating the functionality of your app View: what the user sees and interfaces with Controller: middleman between view and model
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
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,..)
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,..)
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?
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,..
MVC – Tip calculator TipCalculator class Instance variables, init method, accessors, mutators, methods to calculate tip, tip per guest, total bill,..
Your consent to our cookies if you continue to use this website.