Lecture Model View Controller s/w architecture AND general tips on structuring classes.

Slides:



Advertisements
Similar presentations
Lab 9: Code Organization User Interface Lab: GUI Lab October 23 rd, 2013.
Advertisements

Apache Struts Technology
Mr Barton’s Maths Notes
OOP Design Patterns Chapters Design Patterns The main idea behind design patterns is to extract the high level interactions between objects and.
Slides prepared by Rose Williams, Binghamton University Chapter 17 Swing I.
Cosc 4755 Phone programming: GUI Concepts & Threads.
CS 112 GUI 06 May 2008 Bilkent. Java GUI API Containers: ◦ contain other GUI components. E.g, Window, Panel, Applet, Frame Dialog. Components: ◦ Buttons,
Object-Oriented Analysis and Design
Structure of a web application1 Dr Jim Briggs. MVC Structure of a web application2.
Model View Controller (MVC) Architecture. Terminology and History MVC evolved from Smalltalk-80 Has become a key pattern in web based applications – If.
10.1 AWT The AWT classes Users today expect a Graphical User Interface (GUI) Improves application usability Difficult to implement cross-platform.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
Who am I? ● Catalin Comanici ● QA for 10 years, doing test automation for about 6 years ● fun guy and rock star wannabe.
Graphical Tree-Based Scientific Calculator: CalcuWiz Will Ryan Christian Braunlich.
Web Application Architecture: multi-tier (2-tier, 3-tier) & mvc
The Project AH Computing. Functional Requirements  What the product must do!  Examples attractive welcome screen all options available as clickable.
Java Swing - Lecture 1 An Introduction Milena Radenkovic slides originally by Chris Coleman.
Test. A software house decides to develop a DVD renting program. The product manager identifies the following requirements: Every DVD will have a title,
PROG Mobile Java Application Development PROG Mobile Java Application Development Event Handling Creating Menus.
Platforms for Learning in Computer Science July 28, 2005.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Logic and Problem Solving Advanced Computer Programming.
Copyright ©: SAMSUNG & Samsung Hope for Youth. All rights reserved Tutorials Software: Building apps Suitable for: Advanced.
Chapter 5CSA 217 Design in Construction Chapter 5 1.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
Time and Resource Management  How can I keep track of everything I need to do?  How can I make better use of my time?  How can I get more done during.
Event Driven Programming
06/10/ Working with Data. 206/10/2015 Learning Objectives Explain the circumstances when the following might be useful: Disabling buttons and.
Lecture 3 Web Design What makes a "good" website? Getting started on your website. Planning the layout. Picking a theme. Effective Design Tips.
General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. This work is licensed under the Creative.
ISP666 MVC & Design Patterns. Outline Review Event Programming Model Model-View-Controller Revisit Simple Calculator Break Design Patterns Exercise.
Art 315 Lecture 6 Dr. J. Parker. Variables Variables are one of a few key concepts in programming that must be understood. Many engineering/cs students.
(c) University of Washington08-1 CSC 143 Models and Views Reading: Ch. 18.
CS Lecture 01 Frames and Components and events Lynda Thomas
Slides prepared by Rose Williams, Binghamton University ICS201 Lecture 13 : Swing I King Fahd University of Petroleum & Minerals College of Computer Science.
Ch 3-4: GUI Basics Java Software Solutions Foundations of Program Design Sixth Edition by Lewis & Loftus Coming up: GUI Components.
1 Graphical User Interfaces AWT and Swing packages Frames and Panels Components Nested Panels Images Reading for this Lecture: L&L, 3.9 – 3.11.
Architectural Patterns Support Lecture. Software Architecture l Architecture is OVERLOADED System architecture Application architecture l Architecture.
MSc Workshop - © S. Kamin, U. ReddyLect 3 - GUI -1 Lecture 3 - Graphical User Interfaces r GUI toolkits in Java API r JFrame r GUI components.
Timer class and inner classes. Processing timer events Timer is part of javax.swing helps manage activity over time Use it to set up a timer to generate.
GUI Programming Joseph Sant Sheridan College. Agenda Elements of GUI programming Component-Based Programming. Event-Based Programming. A process using.
(1) Introduction to Java GUIs Philip Johnson Collaborative Software Development Laboratory Information and Computer Sciences University of Hawaii Honolulu.
CS 4720 Model-View-Controller CS 4720 – Web & Mobile Systems.
Lecture 4 Page 1 CS 111 Online Modularity and Virtualization CS 111 On-Line MS Program Operating Systems Peter Reiher.
CS Lecture 04 Mice Lynda Thomas
Creating a GUI Class An example of class design using inheritance and interfaces.
Compare and Contrast : Blackboard & a Personal Web Page www3.ltu.edu/~s_schneider/howto/faculty.htm You’ll find this presentation (and another) here :
L10: Model-View-Controller General application structure. User Interface: Role, Requirements, Problems Design patterns: Model – View – Controller, Observer/Observable.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
Slides prepared by Rose Williams, Binghamton University Chapter 20 Java Never Ends.
Swing GUI Components So far, we have written GUI applications which can ‘ draw ’. These applications are simple, yet typical of all Java GUI applications.
View  view  presents the user with a sensory (visual, audio, haptic) representation of the model state  a user interface element (the user interface.
Get awaybackoffon along (with) over together along They don’t get … with each other. back I won’t be able to get … from the office before seven. off.
1 Visual Basic: An Object Oriented Approach 7 – The User interface.
Introduction to Programming and App Inventor. Introduction What is a computer program? Introducing App Inventor Getting hands on with App Inventor.
Modularity Most useful abstractions an OS wants to offer can’t be directly realized by hardware Modularity is one technique the OS uses to provide better.
Structure of a web application
Event-driven programming
Processing Timer Events
Mr F’s Maths Notes Number 10. Surds.
Observer Design Pattern
Enterprise Application Architecture
Timer class and inner classes
You think you can just do your sums in any order you like. THINK AGAIN
Event Driven Programming
An Introduction to VEX IQ Programming with Modkit
Fundamentals of Data Representation
Tonga Institute of Higher Education
Model, View, Controller design pattern
11. MVC SE2811 Software Component Design
11. MVC SE2811 Software Component Design
Presentation transcript:

Lecture Model View Controller s/w architecture AND general tips on structuring classes

Structuring your classes.. When you create your various classes in an application, you want to: Promote reusability (e.g. panels for OK/Cancel buttons might be used in several screens) Minimise code maintenance when something changes (e.g. dB structure, new GUI device ) Maintain as much flexibility as possible

Model View controller MVC is a common s/w architecture pattern used for interactive applications (i.e. applications that have a Graphical User i/f) Model = classes that deal with storing and using data View = classes that deal with the GUI part Controller = (non graphical) classes that bridge the View and the Model

Model Model = classes that deal with storing and using data –If data structure(s) or rules change.. Just change these classes –Can have multiple different GUIs using the same model E.g. calculator functions add/substract etc Different GUIs (standard web, accessible web etc) Aside: Data may be persistent or not persistent – how to deal with persistent?

View = classes that deal with the GUI part –If the GUI changes, don’t (necessarily) need to change the model or control classes E.g. change borders of buttons View

Controller = (non graphical) classes that bridge the View and the Model –Kept separate E.g. control (driver) class with ‘main’ method to run an application Listener classes that trigger behaviour Generally.. Consists of everything that is not the GUI or not directly storing/using data Controller

Example Counter – this screen displays a number in them middle which you can move up by 1 or down by 1 using the buttons A simple Counter 25 Up Down Frame Buttons Label Title

MVC - Counter example Classes needed? For View bit.. –Frame? With some buttons “on” it? Label? Title? For Model bit.. - What “data” is involved? What can be done to it? Is there a dB involved? For Controller bit.. What’s needed apart from GUI and doing the model part? At LEAST 3 classes…

Counter Example For View bit.. –How many classes? Are any “bits” reusable? If not, put in a single class. Otherwise separate out.. For Model bit.. - Need to be able to add, subtract, and store the “data”.. A class that has methods to do this For Controller bit.. - Need a control class to run the counter.. What else?

Counter Example – possible class structure that is MVC compliant For View bit.. –Class for the counterPanel –Class for the counter Frame For Model bit.. - class that has methods to do the increment (up), decrement () etc. i.e. that “does” the data part. For Controller bit.. - class for the listener (that extends actionListener0 - class to run the overall application = 5 classes in total Q: How will they link together? E.g. how do I get the GUI class(es) to “call” the model class methods to add/decrement the counters?

To use MVC in your own GUI applications Often easiest to start with the View first… What class(es) deal just with the visual part (GUI)? = View classes What classes are then needed to deal with manipulating/storing data? = Model What’s left? What control classes are need to respond to things that happen in the view?

Another example A Calculator –What’s the View part? –What’s the model part? –What’s the control part?

Other things.. Giant all purpose class for everything – wrong! –Hard to maintain –Nothing reusable Decide which “parts” might be reusable –E.g. button panels, listener behaviour, –This gives a clue as to how to break out classes Pick out the definable “things” in your app e.g. circle, square – suggests separate classes Keep MVC as a guiding principle but…

Finally As with any design –There is no single “right” answer to how you break your app into classes –But you should design in advance, rather than just letting your code wander along in a single class or two… MVC is one s/w architecture –Some techniques we’ve seen contradict it E.g. implementing listeners directly in the GUI code Anonymous listeners – embedded against the GUI component – has its own advantages.. These approaches have their own merits.. –Be aware of the trade offs.