Model-View-Controller (MVC) Design Pattern



Similar documents
Developing GUI Applications: Architectural Patterns Revisited

Application Programming on the Mac COSC346

Principles of Software Construction: Objects, Design and Concurrency. GUIs with Swing. toad Spring 2013

GUIs with Swing. Principles of Software Construction: Objects, Design, and Concurrency. Jonathan Aldrich and Charlie Garrod Fall 2012

Implementação. Interfaces Pessoa Máquina 2010/ Salvador Abreu baseado em material Alan Dix. Thursday, June 2, 2011

MiniDraw Introducing a framework... and a few patterns

Extending Desktop Applications to the Web

Assignment # 2: Design Patterns and GUIs


GUI Event-Driven Programming

JiST Graphical User Interface Event Viewer. Mark Fong

Integration of DB oriented CAD systems with Product Lifecycle Management

XFlash A Web Application Design Framework with Model-Driven Methodology

Tutorial: Building a Web Application with Struts

Teaching Object-Oriented Software Design within the Context of Software Frameworks

An introduction to creating JSF applications in Rational Application Developer Version 8.0

Java Application Developer Certificate Program Competencies

Syllabus for CS 134 Java Programming

A Review of an MVC Framework based Software Development

Design and Functional Specification

MVC Architecture Driven Design and Implementation of Java Framework for Developing Desktop Application

Nexawebホワイトペーパー. Developing with Nexaweb ~ Nexaweb to Improve Development Productivity and Maintainability

Knowledgebase Article

HP Service Manager. Service Request Catalog (SRC) Tips & Tricks Document

CS 335 Lecture 06 Java Programming GUI and Swing

ARCHITECTURAL DESIGN OF MODERN WEB APPLICATIONS

Commercial software development with the help of J2EE architecture and MVC

AXT JOBS GUI Users Guide

A Structural Design for Web Application Based on Model-view-presenter Viewmodel (Mvpvm) Pattern

Gadget: A Tool for Extracting the Dynamic Structure of Java Programs

Tutorial: Time Of Day Part 2 GUI Design in NetBeans

Stock Trading System Software Design Document

MarkLogic Server. Reference Application Architecture Guide. MarkLogic 8 February, Copyright 2015 MarkLogic Corporation. All rights reserved.

SSC - Web development Model-View-Controller for Java web application development

Swing. A Quick Tutorial on Programming Swing Applications

TATJA: A Test Automation Tool for Java Applets

GUI and Web Programming

Introducing Apache Pivot. Greg Brown, Todd Volkert 6/10/2010

Interfacing SAS Software, Excel, and the Intranet without SAS/Intrnet TM Software or SAS Software for the Personal Computer

Tutorial Reference Manual. Java WireFusion 4.1

Java is commonly used for deploying applications across a network. Compiled Java code

Design Patterns. Design patterns are known solutions for common problems. Design patterns give us a system of names and ideas for common problems.

NASA Workflow Tool. User Guide. September 29, 2010

WebSphere Business Monitor

Introduction to the BackgroundWorker Component in WPF

Swirl. Multiplayer Gaming Simplified. CS4512 Systems Analysis and Design. Assignment Marque Browne Manuel Honegger

Oracle Identity Analytics Architecture. An Oracle White Paper July 2010

Proposal for DSpace Web MVC

Process Document Campus Community: Create Communication Template. Document Generation Date 7/8/2009 Last Changed by Status

How To Develop An App For Ios (Windows)

Customer Bank Account Management System Technical Specification Document

Slides prepared by : Farzana Rahman TESTING WITH JUNIT IN ECLIPSE

High-level Design. What is software architecture?

Software Development Methodologies

Oracle Banking Digital Experience

Design. in NetBeans 6.0

Client Portal Training

Client-server 3-tier N-tier

ADF Code Corner. 66. How-to color-highlight the bar in a graph that represents the current row in the collection. Abstract: twitter.

Table of Contents. Adding Build Targets to the SDK 8 The Android Developer Tools (ADT) Plug-in for Eclipse 9

core. Volume I - Fundamentals Seventh Edition Sun Microsystems Press A Prentice Hall Title ULB Darmstadt

Client-Server Architecture & J2EE Platform Technologies Overview Ahmed K. Ezzat

Generating Automated Test Scripts for AltioLive using QF Test

Hypercosm. Studio.

SAS, Excel, and the Intranet

Training Guide Travel & Expenses How to Find an Expense Report Number or an Employee ID. State of Kansas

Getting Started with Android Programming (5 days) with Android 4.3 Jelly Bean

FIRST HOPE BANK BUSINESS ONLINE BANKING DIRECT CONNECT WITH QUICKBOOKS

JIDE Gantt Chart Developer Guide

Simple Dialog Box Management Handout.pdf. Detailed Instructions

Monitoring Oracle Enterprise Performance Management System Release Deployments from Oracle Enterprise Manager 12c

zen Platform technical white paper

Developing and Implementing Windows-Based Applications With Microsoft Visual C#.NET and Microsoft Visual Studio.NET

Salesforce-Wrike Integration Setup Manual

SAS Add in to MS Office A Tutorial Angela Hall, Zencos Consulting, Cary, NC

SWAN 15.1 Advance user information What s new in SWAN? Introduction of the new user interface. Last update: 28th April 2015

PROCEDURE TO JOIN WEBEX MEETING FOR REMOTE SUPPORT

Reporting Fundamentals for Programmers

ActiveVOS Fundamentals

Programming in C# with Microsoft Visual Studio 2010

PHP FRAMEWORK FOR DATABASE MANAGEMENT BASED ON MVC PATTERN

Source Code Translation

Section 1: Preface Introduction... 1 Users... 1 Assumptions... 2 Other Resources... 2 Conventions... 2 Icons... 2 Text... 2

Web Application Development Using UML

Database Forms and Reports Tutorial

Shark Talent Management System Performance Reports

Programming with Java GUI components

Creating Basic Reports with the SAP Query Tool

Effective Java Programming. measurement as the basis

Transcription:

Model-View-Controller (MVC) Design Pattern Computer Science and Engineering College of Engineering The Ohio State University Lecture 23

Motivation Basic parts of any application: Data being manipulated A user-interface through which this manipulation occurs The data is logically independent from how it is displayed to the user Display should be separately designable/evolvable Example: grade distribution in class Displayed as both pie chart and/or bar chart Anti-example: see BigBlob Presentation, logic, and state all mixed together

Model-View-Controller Pattern Model The data (ie state) Methods for accessing and modifying state View Renders contents of model for user When model changes, view must be updated Controller Translates user actions (ie interactions with view) into operations on the model Example user actions: button clicks, menu selections

Basic Interactions in MVC Input Controller change data user action change display Model Output View

Implementing Basic MVC in Swing Mapping of classes to MVC parts View is a Swing widget (like a JFrame & JButtons) Controller is an ActionListener Model is an ordinary Java class (or database) Alternative mapping View is a Swing widget and includes (inner) ActionListener(s) as event handlers Controller is an ordinary Java class with business logic, invoked by event handlers in view Model is an ordinary Java class (or database) Difference: Where is the ActionListener? Regardless, model and view are completely decoupled (linked only by controller)

Mechanics of Basic MVC Setup Instantiate model Instantiate view Has reference to a controller, initially null Instantiate controller with references to both Controller registers with view, so view now has a (nonnull) reference to controller Execution View recognizes event View calls appropriate method on controller Controller accesses model, possibly updating it If model has been changed, view is updated (via the controller) Example: CalcMVC CalcModel, CalcView, CalcController Note: View includes (gratuitous) reference to model Note 2: The example code has a bug! Can you find it?

Extended Interactions in MVC Input Controller change data user action I have changed Model Output View give me data

Extended Pattern Background: Observer pattern One object is notified of changes in another In extended MVC, view is an observer of model Application within MVC Asynchronous model updates Model changes independent of user actions Associated view must be notified of change in order to know that it must update A model may have multiple views But a view has one model All views have to be updated when model changes

Mechanics of Extended MVC Setup Instantiate model Has reference to view, initially null Instantiate view with reference to model View registers with model Instantiate controller with references to both Controller registers with view Execution View recognizes event View calls appropriate method on controller Controller accesses model, possibly updating it If model has been changed, it notifies all registered views Views then query model for the nature of the change, rendering new information as appropriate

Problems with Classic MVC Controller might need to produce its own output eg Popup menu Some state is shared between controller and view, but does not belong in model eg Selection (highlighted text) Direct manipulation means that user can interact (control) visual elements (views) eg Scrollbar Overall issue: Input and output are often intermingled in a GUI Result: View and controller are tightly coupled

Delegate-Model Pattern Model Data, same as before Delegate Responsible for both input and output A combination of both view and controller Many other names UI-Model Document-View

Basic Interactions in Delegate Model Input Controller change data user action change display Model Output View

Basic Interactions in Delegate Model Input Controller change data I have changed Model Output View Delegate give me data

Mechanics of Delegate Model Setup Instantiate model As with MVC, model does not know/care about UI Instantiate delegate with reference to model Execution Delegate recognizes event and executes appropriate handler for the event Delegate accesses model, possibly updating it If model has been changed, UI is updated Example: CalcV3 CalcModel, CalcViewController Note: CalcModel is exactly the same as with CalcMVC

Notes Litmus test: Swapping out user interface Can the model be used, without modification, by a completely different UI? eg Swing vs console text interface Model can be easily tested with JUnit Model actions should be quick GUI is frozen while model executes Alternative: multithreading, which gets much more complicated

Supplemental Reading Sun Developer Network Java SE Application Design with MVC http://java.sun.com/developer/technicalar ticles/javase/mvc/ OnJava article A Generic MVC Model in Java http://www.onjava.com/pub/a/onjava/20 04/07/07/genericmvc.html

Summary Motivation: Information hiding Data (state) vs user interface State should be agnostic of user interface Model-View-Controller Model contains state (data) View displays model to user (presentation) Controller modifies model (business logic) UI-Model Allows for tight coupling between view and controller Preserves most significant separation