Model View Controller (MVC) Architecture. Terminology and History MVC evolved from Smalltalk-80 Has become a key pattern in web based applications – If.

Slides:



Advertisements
Similar presentations
Understanding an Apps Architecture ASFA Computer Science: Principles Fall 2013.
Advertisements

OOP Design Patterns Chapters Design Patterns The main idea behind design patterns is to extract the high level interactions between objects and.
Week 8, Class 3: Model-View-Controller Model-View-Controller Why? What? How? Example: Barnyard Simon for the Web Question: Where should we use the command.
MVC Nick Lopez Duplication of course material for any commercial purpose without the explicit written permission of the professor is prohibited.
Automating Tasks With Macros
Chapter 12: ADO.NET and ASP.NET Programming with Microsoft Visual Basic.NET, Second Edition.
Graphical User Interface (GUI) Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
Automating Tasks With Macros. 2 Design a switchboard and dialog box for a graphical user interface Database developers interact directly with Access.
Graphical User Interface (GUI) Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Software Architecture Patterns (2). what is architecture? (recap) o an overall blueprint/model describing the structures and properties of a "system"
Object-Oriented Analysis and Design
Application Architectures Vijayan Sugumaran Department of DIS Oakland University.
Part two. 3.2 operating system architecture  Software have two categories  Application software  System software  Application software: consists of.
Course Instructor: Aisha Azeem
The chapter will address the following questions:
Operating system Part two Introduction to computer, 2nd semester, 2010/2011 Mr.Nael Aburas Faculty of Information.
Behavioral Patterns  Behavioral patterns are patterns whose purpose is to facilitate the work of algorithmic calculations and communication between classes.
MODEL VIEW CONTROLLER A Technical Seminar Report submitted to
MVC pattern and implementation in java
Aurora: A Conceptual Model for Web-content Adaptation to Support the Universal Accessibility of Web-based Services Anita W. Huang, Neel Sundaresan Presented.
Programming with Microsoft Visual Basic 2012 Chapter 12: Web Applications.
MVC and MVP. References enter.html enter.html
Model View Controller (MVC) Rick Mercer with a wide variety of others 1.
Concordia University Department of Computer Science and Software Engineering Click to edit Master title style ADVANCED PROGRAM DESIGN WITH C++ Model View.
Copyright © 2012 Accenture All Rights Reserved.Copyright © 2012 Accenture All Rights Reserved. Accenture, its logo, and High Performance Delivered are.
Using Visual Basic 6.0 to Create Web-Based Database Applications
Java Software Solutions Lewis and Loftus Chapter 10 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphical User Interfaces --
Case Study: Game2D with Method Design
MVC CompSci 230 S Software Construction. MVC Architecture  A typical application includes software to  maintain application data,  document text.
Introduction To System Analysis and Design
ISP666 MVC & Design Patterns. Outline Review Event Programming Model Model-View-Controller Revisit Simple Calculator Break Design Patterns Exercise.
(c) University of Washington08-1 CSC 143 Models and Views Reading: Ch. 18.
Visual C++ Programming: Concepts and Projects
CSE 219 Patterns in Programming More Design Patterns.
Chapter 6 – Architectural Design CSE-411, Dr. Shamim H Ripon.
Key Applications Module Lesson 21 — Access Essentials
Lecture # 3 & 4 Chapter # 2 Database System Concepts and Architecture Muhammad Emran Database Systems 1.
3461 Model-View Controller Advanced GUI concepts.
Swing MVC Application Layering A Layer is a collection of components that Perform similar tasks. Perform similar tasks. Isolate implementation details.
Model View Controller (MVC) Bigger than a Pattern: It’s an Architecture Rick Mercer with help from many others 1.
An Introduction to Programming and Object Oriented Design using Java 3 rd Edition. Dec 2007 Jaime Niño Frederick Hosch Chapter 18 Integrating user interface.
1 Java Model-View-Controller - see programming.html#concepts.
Title Carolina First Steering Committee October 9, 2010 Online Voting System Design Yinpeng Li and Tian Cao May 3, 2011.
Model View Controller MVC Web Software Architecture.
©Ian Sommerville 2006Software Engineering, 8th edition. Chapter 18 Slide 1 Software Reuse.
Model View Controller (MVC) Bigger than a Pattern: It’s an Architecture Rick Mercer with help from many of others 1.
XP New Perspectives on Microsoft Office Access 2003 Tutorial 10 1 Microsoft Office Access 2003 Tutorial 10 – Automating Tasks With Macros.
Concordia University Department of Computer Science and Software Engineering Click to edit Master title style ADVANCED PROGRAMMING PRACTICES Model View.
(1) Introduction to Java GUIs Philip Johnson Collaborative Software Development Laboratory Information and Computer Sciences University of Hawaii Honolulu.
Model View Controller (MVC) an architecture Rick Mercer with help from many of others 1.
Lecture Model View Controller s/w architecture AND general tips on structuring classes.
Java - hello world example public class HelloWorld { public static void main (String args[]) { System.out.println("Hello World"); }
Software Architecture for Multimodal Interactive Systems : Voice-enabled Graphical Notebook.
High degree of user interaction Interactive Systems: Model View Controller Presentation-abstraction-control.
MODEL VIEW CONTROLLER PATTERN. Model View Controller MVC is a time tested method of separating the user interface of an application from its Domain Logic.
Imposing MVC design sample in.NET. Design patterns are very useful to solve complex design issues if used well. The primary concept of the Model View.
J2EE Platform Overview (Application Architecture)
Java Beans Sagun Dhakhwa.
MVC and other n-tier Architectures
Architectural Patterns for Interactive Software
Understand Windows Forms Applications and Console-based Applications
CS102 – Bilkent University
Model-View-Controller Patterns and Frameworks
Advanced Program Design with C++
Advanced ProgramMING Practices
DATABASE DESIGN & DEVELOPMENT
Advanced ProgramMING Practices
Model, View, Controller design pattern
Presentation transcript:

Model View Controller (MVC) Architecture

Terminology and History MVC evolved from Smalltalk-80 Has become a key pattern in web based applications – If you do not understand the MVC pattern you cannot succeed in web development – Popular frameworks that support MVC Struts (apache.org).NET (Microsoft)

Terminology and History The MVC paradigm is a way of breaking an application, or even just a piece of an application's interface, into three parts: the model, the view, and the controller. MVC was originally developed to map the traditional input, processing, output roles into the GUI realm: Input --> Processing --> Output Controller --> Model --> View

The MVC Paradigm – Basic Model

Model ViewController Invoke methods on the Model public API Query the Model State Notify View of Change In Model State Select View User Actions/Commands Events Method Invocations

The Model In MVC, the model is the code that carries out some task. It is built with no necessary concern for how it will "look and feel" when presented to the user. A model is an object representing data or even activity, e.g. a database table or even some plant-floor production-machine process. The model – manages the behavior and data of the application domain, – responds to requests for information about its state and – responds to instructions to change state.

The Model The model often represents enterprise data and the business rules that govern access to and updates of this data. Often the model serves as a software approximation to a real-world process, so simple real-world modeling techniques apply when defining the model. The model is the piece that represents the state and low-level behavior of the component. It manages the state and conducts all transformations on that state.

The Model The model has no specific knowledge of either – its controllers or – its views. However, a model must be able to "register" views and it must be able to "notify" all of its registered views when any of its functions cause its state to be changed. The system itself maintains links between model and views and notifies the views when the model changes state. The view is the piece that manages the visual display of the state represented by the model. A model can have more than one view.

The Model Note that the model may not necessarily have a persistent data store (database), such as when it deals with a control on a GUI screen. It has a purely functional interface, meaning that it has a set of public functions that can be used to achieve all of its functionality. Some of the functions are query methods that permit a "user" to get information about the current state of the model. Others are mutator methods that permit the state to be modified. setTemperature(temp) and getTemperature() – Temperature Model addItem(item, category), setScore(item, student, score)… - Gradebook

Model Example public class TemperatureModel extends java.util.Observable { public double getF(){return temperatureF;} public double getC(){return (temperatureF ) * 5.0 / 9.0;} public void setF(double tempF) { temperatureF = tempF; setChanged(); notifyObservers(); } public void setC(double tempC) { temperatureF = tempC*9.0/ ; setChanged(); notifyObservers(); } private double temperatureF = 32.0; }

View A view is some form of visualization of the state of the model. The view manages the graphical and/or textual output to the portion of the bitmapped display that is allocated to its application. The view renders the contents of a model. It accesses enterprise data through the model and specifies how that data should be presented. The view is responsible for mapping graphics onto a device. A view typically has a one to one correspondence with a display surface and knows how to render to it. A view attaches to a model and renders its contents to the display surface.

View A model in MVC can have several views. For examples the rows and columns view of a spreadsheet and the pie chart view of some column in the same spreadsheet. A view provides graphical user interface (GUI) components for a model. It gets the values that it displays by querying the model of which it is a view. When a user manipulates a view of a model, the view informs a controller of the desired change.

View - Code Segment TemperatureGUI(String label, TemperatureModel model, int h, int v) { this.label = label; this.model = model; temperatureFrame = new Frame(label); temperatureFrame.add("Center", display); Panel buttons = new Panel(); buttons.add(upButton); buttons.add(downButton); temperatureFrame.add("South", buttons); temperatureFrame.addWindowListener(new CloseListener()); model.addObserver(this); // Connect the View to the Model temperatureFrame.setSize(200,100); temperatureFrame.setLocation(h, v); temperatureFrame.setVisible(true); }

Controllers Views in MVC are associated with controllers that update the model as necessary when a user interacts with an associated view. The controller can call mutator methods of the model to get it to update its state. Of course, then the model will notify ALL registered views that a change has been made and so they will update what they display to the user as appropriate

Controllers A controller offers facilities to change the state of the model. The controller interprets the mouse and keyboard inputs from the user, commanding the model and/or the view to change as appropriate. A controller is the means by which the user interacts with the application. A controller accepts input from the user and instructs the model and view to perform actions based on that input. In effect, the controller is responsible for mapping end-user action to application response.

Controllers The controller translates interactions with the view into actions to be performed by the model. In a stand-alone GUI client, user interactions could be button clicks or menu selections, whereas in a Web application they appear as HTTP GET and POST requests. The actions performed by the model include activating business processes or changing the state of the model.

Controllers Based on the user interactions and the outcome of the model actions, the controller responds by selecting an appropriate view. The controller is the piece that manages user interaction with the model. It provides the mechanism by which changes are made to the state of the model.

Visual Examples

View 1

View 2

View 3

View 4

Fun (no grade) Project Implement the above temperature MVC using a struts

The MVC Paradigm - Improved

MVC - Web Based Model Later on in this course I will ask you what is bad with the above diagram. Might make a good exam question.

Additional Resources For those of you that want other references – controller controller – ml (simple implementation - I borrowed from it) ml – (Struts – get familiar with this if you plan to work in Java/J2EE)