Pattern: Model-View-Controller (MVC) Beat Generator Example. Model-View-Controller. Model-View-Controller

Similar documents
CS 520/620 Advanced Software Engineering Fall September 27, 2016

CAS 703 Software Design

MVC / MVP Mei Nagappan

Design Patterns Reid Holmes

MVC / MVP Reid Holmes

Core Java Syllabus. Pre-requisite / Target Audience: C language skills (Good to Have)

CPSC 310 Software Engineering. Lecture 11. Design Patterns

Modellistica Medica. Maria Grazia Pia, INFN Genova. Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico

CSE 70 Final Exam Fall 2009

CSE 401/M501 Compilers

Model-View-Controller Patterns and Frameworks. MVC Context

BFH/HTA Biel/DUE/Course 355/ Software Engineering 2

Model-View Controller IAT351

Design Patterns Reid Holmes

ITP 342 Mobile App Development. Model View Controller

Android PC Splash Brothers Design Specifications

Idioms and Design Patterns. Martin Skogevall IDE, Mälardalen University

DESIGN PATTERN - INTERVIEW QUESTIONS

Chapter 5 Object-Oriented Programming

Cocoa Design Patterns. Erik M. Buck October 17, 2009

CSC 222: Object-Oriented Programming. Fall 2015

6.001 Notes: Section 8.1

ITP 342 Mobile App Development. Model View Controller

CS342: Software Design. Oct 9, 2017

CS 349 / SE 382 Custom Components. Professor Michael Terry February 6, 2009

OODP Session 4. Web Page: Visiting Hours: Tuesday 17:00 to 19:00

Object Oriented Paradigm

Program to an Interface, Not an Implementation

Design Patterns. Comp2110 Software Design. Department of Computer Science Australian National University. Second Semester

The Visitor Pattern. Design Patterns In Java Bob Tarr

Software Design Patterns. Background 1. Background 2. Jonathan I. Maletic, Ph.D.

COURSE 2 DESIGN PATTERNS

CS246 Software Abstraction and Specification Final Examination

Software System/Design & Architecture. Eng.Muhammad Fahad Khan Assistant Professor Department of Software Engineering

Object-Oriented Oriented Programming

The physicist said "We need to model the friction in the brake pads and the resultant temperature rise, see if we can work out why they failed".

Design Patterns. Observations. Electrical Engineering Patterns. Mechanical Engineering Patterns

Topics in Object-Oriented Design Patterns

The Strategy Pattern Design Principle: Design Principle: Design Principle:

Inside Smalltalk MVC: Patterns for GUI Programming

Chapter 6 Architectural Design. Lecture 1. Chapter 6 Architectural design

Design Patterns. Gunnar Gotshalks A4-1

CSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich

Introduction to concurrency and GUIs

An Introduction to Patterns

Introduction to GUIs. Principles of Software Construction: Objects, Design, and Concurrency. Jonathan Aldrich and Charlie Garrod Fall 2014

Design Patterns. Lecture 10: OOP, autumn 2003

What are patterns? Design Patterns. Design patterns. Creational patterns. The factory pattern. Factory pattern structure. Lecture 10: OOP, autumn 2003

5/9/2014. Recall the design process. Lecture 1. Establishing the overall structureof a software system. Topics covered

CS 520/620 Advanced Software Engineering Spring February 11, 2016

Adapter pattern. Acknowledgement: Freeman & Freeman

Lecture 1. Chapter 6 Architectural design

Object Oriented Design & Patterns. Part 1

Produced by. Design Patterns. MSc in Communications Software. Eamonn de Leastar

The Design Patterns Matrix From Analysis to Implementation

Class Inheritance and OLE Integration (Formerly the Common Object Model)

Work groups meeting 3

Design Patterns. Manuel Mastrofini. Systems Engineering and Web Services. University of Rome Tor Vergata June 2011

CS 116x Winter 2015 Craig S. Kaplan. Module 03 Graphical User Interfaces. Topics

Object- Oriented Design with UML and Java Part I: Fundamentals

An Introduction to Patterns

Design Patterns. GoF design patterns catalog

Design Patterns Design patterns advantages:

Design Pattern What is a Design Pattern? Design Pattern Elements. Almas Ansari Page 1

Control Message. Abstract. Microthread pattern?, Protocol pattern?, Rendezvous pattern? [maybe not applicable yet?]

Object Relationships

Design Process Overview. At Each Level of Abstraction. Design Phases. Design Phases James M. Bieman

Forth Meets Smalltalk. A Presentation to SVFIG October 23, 2010 by Douglas B. Hoffman

Objects and Classes. Amirishetty Anjan Kumar. November 27, Computer Science and Engineering Indian Institue of Technology Bombay

Ling/CSE 472: Introduction to Computational Linguistics. 5/4/17 Parsing

Produced by. Design Patterns. MSc in Communications Software. Eamonn de Leastar

Model-view-controller. An architecture for UI

EPL 603 TOPICS IN SOFTWARE ENGINEERING. Lab 6: Design Patterns

Solution register itself

What is a Pattern? Lecture 40: Design Patterns. Elements of Design Patterns. What are design patterns?

6.001 Notes: Section 15.1

Design Patterns V Structural Design Patterns, 2

Software Architecture

Chapter 6 Architectural Design. Chapter 6 Architectural design

04 Webservices. Web APIs REST Coulouris. Roy Fielding, Aphrodite, chp.9. Chp 5/6

Lecture 20: Design Patterns II

1. Write two major differences between Object-oriented programming and procedural programming?

Design Patterns: Structural and Behavioural

What's New in Sitecore CMS 6.4

CSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich

Jonathan Aldrich Charlie Garrod

All the Swing components start with J. The hierarchy diagram is shown below. JComponent is the base class.

Model-view-controller View hierarchy Observer

Reasons to use a constraint-based product configuration model.

UNIT V *********************************************************************************************

Architectural Styles II

Architectural Styles - Finale

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University

Developing Reusable Device Drivers for MCU's

Composite Pattern. IV.4 Structural Pattern

Organization of User Interface Software

Programming Language Pragmatics

Designing Procedural 4GL Applications through UML Modeling

Think of drawing/diagramming editors. ECE450 Software Engineering II. The problem. The Composite pattern

Patterns Architectural Styles Archetypes

Transcription:

Pattern: Model-View-Controller (MVC) Beat Generator MVC is an architectural pattern it specifies code organization at a higher level than a design pattern. (But the idea is similar it tells you how to organize things.) controller has methods for the conceptual operations There are many related patterns (e.g. MVP) and varying interpretations, but The key idea is separation of concerns separating distinct functionality within an application's code to allow reuse of code across applications development of multiple UIs developer specialization and focus parallel development by separate teams view provides the UI model contains the application state, and manages/ notifies observers CPSC 329: Software Development Fall 2017 124 CPSC 329: Software Development Fall 2017 126 Model-View-Controller MVC divides an application's code into three parts: the model stores data objects and business rules data objects are the basic noun objects needed by the system business rules govern the manipulation of the model e.g. define what updates are allowed the view is what the user sees (user interface) displays the data translates user interactions into conceptual actions the controller is the glue in between contains the application logic translates user actions into model updates selects the view Model-View-Controller 1. the user does something to the view e.g. clicks a button 2. do this task 3. modify interface (*) 4. I've changed! 5. Tell me your state! (**) (*) changes to the components shown, whether they are enabled/disabled, etc not simply refreshing a component to show new model data (**) in pull model 3. change state CPSC 329: Software Development Fall 2017 125 CPSC 329: Software Development Fall 2017 127

Model-View-Controller The pattern is derived from familiar concepts: single purpose separate view from the rest loose coupling, especially with respect to the model model does not know about view or controllers information hiding / code to the interface to isolate change and allow substitution of parts / reuse each view can consist of multiple classes model can consist of multiple classes can have different controllers for different views (e.g. views have different functionality) controllers can also implement Observer if they need to be notified of model updates CPSC 329: Software Development Fall 2017 129 CPSC 329: Software Development Fall 2017 131 Basic MVC Observer pattern allows model to be decoupled from view (model can notify view of updates without having to know about view) can utilize Strategy pattern for views so one controller can work with different views (e.g. similar functionality in views but different realizations) beat example lacked an explicit Observable instead it combined model and observable in BeatGenerator (a reason two kinds of observers) CPSC 329: Software Development Fall 2017 130 CPSC 329: Software Development Fall 2017 132

Model-View-Controller can utilize Strategy pattern with controllers to reuse same view with different models The ideas of MVC can be applied at different levels. organizing the whole program individual components e.g. JSlider, JList, JButton,... (technically Swing's version is a separable model architecture because view and controller are combined into one) CPSC 329: Software Development Fall 2017 133 CPSC 329: Software Development Fall 2017 135 fully generalized, every part view, controller, model is hidden behind an interface to decouple from specific concrete classes Views don't have to be user interfaces as such. e.g. how could MVC be used to allow one Game class to work with both standalone and network versions? CPSC 329: Software Development Fall 2017 134 CPSC 329: Software Development Fall 2017 136

Pattern: Visitor Intent. define a new operation without changing the classes of the elements on which it operates. a shopping cart containing a list of items would like to calculate postage costs for the contents of the cart calculate total order amount for the contents of the cart print the contents of the cart CPSC 329: Software Development Fall 2017 141 CPSC 329: Software Development Fall 2017 143 Pattern: Visitor Intent. define a new operation without changing the classes of the elements on which it operates Code structure. Visitor has a method for each type of element concrete visitors are the operations ObjectStructure is the collection of elements can define other visitors e.g. to print cart CPSC 329: Software Development Fall 2017 142 CPSC 329: Software Development Fall 2017 http://java.dzone.com/articles/design-patterns-visitor 144

Pattern: Visitor Notes. variation is in the action being done, not the traversal itself requires that things being visited be designed for the pattern, but additional changes for new visitors is not required new types of things being visited requires changes to the Visitor interface (or use of reflection) Visitor pattern is best when new actions are more likely than new things define CD, DVD, etc similarly CPSC 329: Software Development Fall 2017 145 CPSC 329: Software Development Fall 2017 147 s compilers processing of abstract syntax tree during code generation HTML/XML document formatting double dispatch - because overloaded methods are resolved at compile time visitor.visit(item) wouldn't compile CPSC 329: Software Development Fall 2017 146 CPSC 329: Software Development Fall 2017 148