Swing and MVCS1 2015 CompSci 230 Software Construction.

Slides:



Advertisements
Similar presentations
Ch 3 System Development Environment
Advertisements

Software Processes Coherent sets of activities for specifying, designing, implementing and testing software systems.
Presented by Benjamin Kehrer [CSCI 360, CofC, 03/17/08]
Architectural patterns1. 2 Patterns Architectural patterns –Fundamental structural organization for software systems. –High-level subdivision of the system.
COSC 3461: Module 8 Model-View-Controller (MVC) Architecture.
Model-View-Controller Architecture Hector Raphael Mojica.
1 Chapter 7 Graphics and Event Handling. 2 Overview The java.awt and javax.swing packages and their subpackages support graphics and event handling. Many.
Graphical User Interface (GUI) Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
Overview of Swing’s MVC Architecture By Geoffrey Steffens (BCSi), Socket Software, Australia Copyright © Socket Software, 2002.
THE SWING UI TOOLKIT Mostly from “The Swing Connection”The Swing Connection.
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
Java Programming, 3e Concepts and Techniques Chapter 1 An Introduction to Java and Program Design.
Graphical User Interface (GUI) Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Object-Oriented Analysis and Design
Application Architectures Vijayan Sugumaran Department of DIS Oakland University.
Stanford hci group / cs376 research topics in human-computer interaction UI Software Tools Scott Klemmer 27 October 2005.
Introduction to Java Swing “We are the sultans of swing” – Mark Knopfler.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 18 Slide 1 Software Reuse 2.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 8 Slide 1 Software Prototyping l Rapid software development to validate requirements l.
Java Programming, 2E Introductory Concepts and Techniques Chapter 1 An Introduction to Java and Program Design.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 8 Slide 1 Software Prototyping l Rapid software development to validate requirements.
©Ian Sommerville 2006Software Engineering, 8th edition. Chapter 18 Slide 1 Software Reuse.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 14Slide 1 Design with Reuse l Building software from reusable components.
MVC pattern and implementation in java
Model View Controller (MVC) Rick Mercer with a wide variety of others 1.
Copyright © 2012 Accenture All Rights Reserved.Copyright © 2012 Accenture All Rights Reserved. Accenture, its logo, and High Performance Delivered are.
Todd Snyder Development Team Lead Infragistics Experience Design Group.
Course Presentation EEL5881, Fall, 2003 Project: Network Reliability Tests Project: Network Reliability Tests Team: Gladiator Team: Gladiator Shuxin Li.
Model-View-Controller Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University.
Computer Science Wi-Fi App using J2ME and MVC Architecture Advisor : Dr. Chung-E Wang Department of Computer Science Sacramento State University Date:
MVC CompSci 230 S Software Construction. MVC Architecture  A typical application includes software to  maintain application data,  document text.
Java Swing, Events and MVC Optional Readings: Eckel’s Thinking in Java: Chap 14 (
JavaBeans Components. To understand JavaBeans…  Proficient experience with the Java language required  Knowledge of classes and interfaces  Object-Oriented.
Putting together a complete system Chapter 10. Overview  Design a modest but complete system  A collection of objects work together to solve a problem.
JSF Introduction Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission.
(c) University of Washington08-1 CSC 143 Models and Views Reading: Ch. 18.
Chapter 6 – Architectural Design CSE-411, Dr. Shamim H Ripon.
COMP 6471 Software Design Methodologies Winter 2006 Dr Greg Butler
Systems Analysis and Design in a Changing World, 3rd Edition
3461 Model-View Controller Advanced GUI concepts.
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,
SWING 101. IF YOU GET LOST - IMPORTANT LINKS  Swing articles:
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 35 MVC and Swing MVC.
Java GUI building approaches Aleksandar Kartelj Faculty of Mathematics, Belgrade 11 th Workshop “Software Engineering Education and.
Model View Controller MVC Web Software Architecture.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
Model View Controller (MVC) Bigger than a Pattern: It’s an Architecture Rick Mercer with help from many of others 1.
Software Prototyping Rapid software development to validate requirements.
Swinging in Your Java Playground. Background Swing is a part of the Java Foundation Classes (JFC). The JFC is made up of features intended to give a programmer.
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
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.
Model View Controller (MVC) an architecture Rick Mercer with help from many of others 1.
L10: Model-View-Controller General application structure. User Interface: Role, Requirements, Problems Design patterns: Model – View – Controller, Observer/Observable.
Java Swing, Events Readings: Just Java 2: Chap 19 & 21, or Eckel’s Thinking in Java: Chap 14 Slide credits to CMPUT 301, Department of Computing Science.
Java - hello world example public class HelloWorld { public static void main (String args[]) { System.out.println("Hello World"); }
Past Computing Environments: Swing Ian Smith UI Toolkits (History Lesson) 4 Programming tools for building interfaces 4 Originally in Java you had AWT.
1 Visual Basic: An Object Oriented Approach 7 – The User interface.
Software Engineering cosc 4359 Spring 2017.
J2EE Platform Overview (Application Architecture)
Design Patterns Source: “Design Patterns”, Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides And Created.
CompSci 280 S Introduction to Software Development
Support for the Development of Interactive Systems
Java Look-and-Feel Design Guidelines
Observer Design Pattern
Building Graphical User Interface with Swing a short introduction
Composite Pattern Context:
Model, View, Controller design pattern
Presentation transcript:

Swing and MVCS CompSci 230 Software Construction

Learning Goals COMPSCI 230: Swing MVC2  You will learn an architectural design pattern: the MVC  You will start to understand why high-level design is important  You will learn how Swing implements MVC  You will start to understand why architecture is an art, not a science.

Swing COMPSCI 230: Swing MVC3  “The overall goal for the Swing project was:  To build a set of extensible GUI components to enable developers to more rapidly develop powerful Java front ends for commercial applications.  “To this end, the Swing team established a set of design goals early in the project that drove the resulting architecture. These guidelines mandated that Swing would: 1. Be implemented entirely in Java to promote cross-platform consistency and easier maintenance. 2. Provide a single API capable of supporting multiple look-and-feels so that developers and end-users would not be locked into a single look-and-feel. 3. Enable the power of model-driven programming without requiring it in the highest-level API. 4. Adhere to JavaBeans TM design principles to ensure that components behave well in IDEs and builder tools. 5. Provide compatibility with AWT APIs where there is overlapping, to leverage the AWT knowledge base and ease porting.” [Amy Fowler, “A Swing Architecture Overview”, Sun Microsystems, A corrupted version is available at April Archival version: ]

Pluggable look and feel COMPSCI 230 Software Design & Construction 4 With a Swing application, it is possible to change the look- and-feel at run-time. What technique do you think has been used in implementing this feature? JButton setUI( delegate : ButtonUI ) : void > ButtonUI paint( g : Graphics ) : void Implemented by one class for each different look-and- feel, e.g. Windows, Metal, Motif.

Swing’s Model-based Architecture COMPSCI 230: Swing MVC5  “Swing architecture is rooted in the model-view-controller (MVC) design that dates back to SmallTalk.  “MVC architecture calls for a visual application to be broken up into three separate parts:  A model that represents the data for the application  The view that is the visual representation of that data  A controller that takes user input on the view and translates that to changes in the model.” [Amy Fowler, ibid.]

MVC: According to Wikipedia COMPSCI 230: Swing MVC6  A controller can send commands to the model to update the model's state (e.g., editing a document).  It can also send commands to its associated view to change the view's presentation of the model (e.g., by scrolling through a document).  A model notifies its associated views and controllers when there has been a change in its state.  This notification allows the views to produce updated output, and the controllers to change the available set of commands.  In some cases an MVC implementation may instead be 'passive' and other components must poll the model for updates rather than being notified.  A view requests information from the model that it uses to generate an output representation to the user. [

Spaghetti Code vs Modular Design COMPSCI 230: Swing MVC7  Spaghetti Code  Haphazard connections, probably grown over time  No visible cohesive groups  High coupling: high interaction between random parts  Understand it: all or nothing  Modular System  High cohesion within modules  Low coupling between modules  Modules can be understood separately  Interaction between modules is easily-understood and thoroughly specified Both examples have 10 modules and 13 connections!

Architectural Design History of Swing [Fowler, ibid. ] COMPSCI 230: Swing MVC8  “The first Swing prototype followed a traditional MVC separation in which each component  had a separate model object and  delegated its look-and-feel implementation to separate view and controller objects.  “I quickly discovered that this split didn’t work well in practical terms  because the view and controller objects required a tight coupling  (for example, it was very difficult to write a generic controller that didn’t know specifics about the view).  “So I collapsed these two entities into a single UI (user-interface) object, as shown in this diagram:”

Separable Model Architecture [Fowler, ibid. ] COMPSCI 230: Swing MVC9  “In the world of Swing, this new quasi-MVC design is sometimes referred to as a separable model architecture.  “Swing’s separable model design treats the model part of a component as a separate element, just as the MVC design does.  But Swing collapses the view and controller parts of each component into a single UI (user-interface) object.  “… as an application developer, you should think of a component’s view/controller responsibilities as being handled by the generic component class (such as Jbutton, JTree, and so on).  The component class then delegates the look-and-feel specific aspects of those responsibilities to the UI object that is provided by the currently installed look-and-feel.” [Amy Fowler, ibid.]

GUI-state models, Application-data models COMPSCI 230: Swing MVC10  “GUI state models are interfaces that define the visual status of a GUI control, such as  whether a button is pressed or armed, or  which items are selected in a list.  “An application-data model is an interface that represents some quantifiable data that has meaning primarily in the context of the application, such as  the value of a cell in a table or  the items displayed in a list.  “Of course, with some components, the model categorization falls somewhere between GUI state models and application-data models … This is the case with  the BoundedRangeModel or  JProgressBar. ”

Learning Goals: Review COMPSCI 230: Swing MVC11  You will learn an architectural design pattern: the MVC  You will start to understand why high-level design is important  You will learn how Swing implements MVC  You will start to understand why architecture is an art, not a science.