ISP666 MVC & Design Patterns. Outline Review Event Programming Model Model-View-Controller Revisit Simple Calculator Break Design Patterns Exercise.

Slides:



Advertisements
Similar presentations
SE2811 Week 7, Class 2 The Gang of Four and more … Lab Thursday: Quiz SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors: Dr. Yoder.
Advertisements

OOP Design Patterns Chapters Design Patterns The main idea behind design patterns is to extract the high level interactions between objects and.
James Tam Introduction To Design Patterns You will learn about design techniques that have been successfully applied to different scenarios.
DESIGN PATTERNS OZGUR RAHMI DONMEZ.
2 Object-Oriented Analysis and Design with the Unified Process Objectives  Explain how statecharts can be used to describe system behaviors  Use statecharts.
R R R CSE870: Advanced Software Engineering: Frameworks (Cheng, Sp2003)1 Frameworks A Brief Introduction.
Graphical User Interface (GUI) Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
Design Patterns Daniel McClain. Background What are they?  Way of recording solutions to recurring design problems History  “A Pattern Language: Towns,
James Tam Introduction To Design Patterns You will learn about design techniques that have been successfully applied to different scenarios.
Satzinger, Jackson, and Burd Object-Orieneted Analysis & Design
Graphical User Interface (GUI) Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Spring 2010CS 2251 Design Patterns. Spring 2010CS 2252 What is a Design Pattern? "a general reusable solution to a commonly occurring problem in software.
K. Stirewalt CSE 335: Software Design Outline of course topics Foundational OO concepts Synthetic concepts: –Program families, program fragments, and abstract.
© Copyright Eliyahu Brutman Programming Techniques Course.
Design Patterns Based on Design Patterns. Elements of Reusable Object-Oriented Software. by E.Gamma, R. Helm, R. Johnson,J. Vlissides.
Adapters Presented By Zachary Dea. Definition A pattern found in class diagrams in which you are able to reuse an ‘adaptee’ class by providing a class,
Object-Oriented Analysis and Design
Marcelo Santos – OOAD-CDT309, Spring 2008, IDE-MdH 1 Object-Oriented Analysis and Design - CDT309 Period 4, Spring 2008 Design Patterns: someone has already.
PRESENTED BY SANGEETA MEHTA EECS810 UNIVERSITY OF KANSAS OCTOBER 2008 Design Patterns.
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
Design Patterns academy.zariba.com 1. Lecture Content 1.What are Design Patterns? 2.Creational 3.Structural 4.Behavioral 5.Architectural 6.Design Patterns.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
Design Patterns Ric Holt & Sarah Nadi U Waterloo, March 2010.
MVC pattern and implementation in java
Microsoft Visual Basic 2005: Reloaded Second Edition
MVC and MVP. References enter.html enter.html
Software Design Refinement Using Design Patterns Instructor: Dr. Hany H. Ammar Dept. of Computer Science and Electrical Engineering, WVU.
Model View Controller (MVC) Rick Mercer with a wide variety of others 1.
Implementing Design Patterns Using Java St. Louis Java Special Interest Group Eric M. Burke Object Computing, Inc. Presented on July 9, 1998 (updated July.
An Introduction to Visual Basic
CHAPTER ONE Problem Solving and the Object- Oriented Paradigm.
Case Studies on Design Patterns Design Refinements Examples.
1 SAD2 - UML 4 th Lecture Class Diagram in Construction Phase Patterns Case Study Lecturer: Dr Dimitrios Makris
SOEN 6011 Software Engineering Processes Section SS Fall 2007 Dr Greg Butler
BTS430 Systems Analysis and Design using UML Design Patterns.
Patterns in programming 1. What are patterns? “A design pattern is a general, reusable solution to a commonly occurring problem in software. A design.
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 27. Review UML dynamic view – State Diagrams.
CS 325: Software Engineering February 12, 2015 Applying Responsibility-Assignment Patterns Design Patterns Situation-Specific Patterns Responsibility-Assignment.
Y2 eProjects Session 4 – Advanced Topics. Objectives  Dynamic Models  Design Patterns (Optional)  Software testing (for S4) ACCP i7.1\Sem3_4\eProject\T4.
Chapter 6 – Architectural Design CSE-411, Dr. Shamim H Ripon.
Behavioral Design Patterns Morteza Yousefi University Of Science & Technology Of Mazandaran 1of 27Behavioral Design Patterns.
18 April 2005CSci 210 Spring Design Patterns 1 CSci 210.
GoF: Document Editor Example Rebecca Miller-Webster.
CSE 403 Lecture 14 Design Patterns. Today’s educational objective Understand the basics of design patterns Be able to distinguish them from design approaches.
Model View Controller (MVC) Bigger than a Pattern: It’s an Architecture Rick Mercer with help from many others 1.
1 CSC 222: Object-Oriented Programming Spring 2012 netBeans & GUIBuilder  netBeans IDE create/edit/run a project  GUIBuilder JFrame, JButton, JTextField,
1 A Brief Introduction to Design Patterns Based on materials from Doug Schmidt 1.
Design Patterns CSIS 3701: Advanced Object Oriented Programming.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Title Carolina First Steering Committee October 9, 2010 Online Voting System Design Yinpeng Li and Tian Cao May 3, 2011.
05/26/2004www.indyjug.net1 Indy Java User’s Group May Knowledge Services, Inc.
Model View Controller (MVC) Bigger than a Pattern: It’s an Architecture Rick Mercer with help from many of others 1.
DESIGN PATTERNS COMMONLY USED PATTERNS What is a design pattern ? Defining certain rules to tackle a particular kind of problem in software development.
CS 151: Object-Oriented Design October 15 Class Meeting Department of Computer Science San Jose State University Fall 2013 Instructor: Ron Mak
Design Patterns: Elements of Reusable Object- Orientated Software Gamma, Helm, Johnson, Vlissides Presented By: David Williams.
Concordia University Department of Computer Science and Software Engineering Click to edit Master title style ADVANCED PROGRAMMING PRACTICES Model View.
1 CSE 331 Model/View Separation and Observer Pattern slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia.
Design Patterns in Context ©SoftMoore ConsultingSlide 1.
Design Patterns CSCE 315 – Programming Studio Spring 2013.
Programming Logic and Design Seventh Edition Chapter 12 Event-Driven GUI Programming, Multithreading, and Animation.
Design Patterns Source: “Design Patterns”, Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides And Created.
Software Design Refinement Using Design Patterns
CMPE 135: Object-Oriented Analysis and Design October 24 Class Meeting
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2005 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
CMPE 135 Object-Oriented Analysis and Design March 21 Class Meeting
Advanced ProgramMING Practices
Design Patterns Imran Rashid CTO at ManiWeber Technologies.
Advanced ProgramMING Practices
Presentation transcript:

ISP666 MVC & Design Patterns

Outline Review Event Programming Model Model-View-Controller Revisit Simple Calculator Break Design Patterns Exercise

Event-driven programming It gives user full control For application programmer, it is about two things: –Registering event listeners –Writing event-handling code for the listeners Caution –Keep your event-handling code short and run fast Why?

How to connect application logic to GUI? Model: information the application is dealing with –e.g. Chips, circuits in case of a ECAD tool –e.g. Student, class data in case of a class registration system View: visual display of the model –Diagrams, images –Tables –Buttons, menus Controller: connecting the two

Model-View-Controller (MVC) Model and View must be separated! Same model may have multiple views E.g. A demographic data may be displayed as a table or a graph Same view may be used to deal with multiple Models Code reuse View and controller might be combined

MVC a = 50% b = 30% c = 20% model

Model Class Keep references to all its views –May not be necessary if all the possible changes of model are from view Notify all its views if its value changed –Could be handled in views and controller if all the change come from view

Model Class Keep a reference to its model Notify the model when it is changed by the user action

Controller Translate user action event to method invocation on model Its functionality may spread in multiple classes –In Event-handlers

Simple Calculator Model: a math expression and a result View: strings in text box, buttons Controller: event handling code for key buttons and text boxes 12*(7.5-1) / * + - ().= Clear

MVC Discussion A well architectured GUI application is said to always separate View and Model Discuss –Will it make the code shorter? –What are the benefits? break

Interaction among Objects Can be very complicated –Composite, aggregate, inheritance We also strive to achieve –Reusability of code –Extensibility (flexibility) of our system Ad hoc solutions may not work well

Design Patterns Famous book of the Gang of Four (aka GoF book) –Gamma, Helm, Johnson & Vlissides –“Design Patterns – Elements of Reusable Object-Oriented Software”, 1995 Elegant solutions to recurring problems in Object-Oriented software design

Type of Patterns Creational Pattern –Object creation Structural Pattern –Composition of classes and objects Behavioral Pattern –Characteristic of object interaction

UML Class Diagram Notation

Abstract Factory Pattern Application does not need to know which kind of button should be drawn (Motif Button, or Windows Button) It just draw a button, system will draw the current button according to current look-and- feel setting. Creational Change look-and-feel with one line of code, how?

Abstract Factory

Adaptor Pattern Aka. Wrapper Pattern Let different classes conform to the same interface Structural There's an existing TextView class that you want to add it to your graphic editor program as a Shape object (like LineShape, PolygonShape, etc.), but TextView is not created with Shape interface in mind. What to do?

Class Adaptor

Object Adaptor

Strategy Pattern Aka. Policy Define a family of algorithms, and make them interchangable for clients that use it Several different line-breaking algorithms are available for a editor you are developing, e.g. HtmlLineBreaker, TexLineBreaker, ArrayLineBreaker, etc. Now you don't want rendering code to explicitly ask for an algorithm (for the sake of MVC) but still get an appropriate algorithm given the type of the content. How to achieve that?

Strategy

Exercise Let's design an arcade game, say, a “bombing the enemy submarines” game. –You control a surface ship to bomb enemy submarines below –Enemy submarines will fire back, there are different types of subs, firing different missiles at you It should be played on the Web, on cell phone, or download to the computer for offline play. More content can be added by user through scripting.