CS 151: Object-Oriented Design October 15 Class Meeting Department of Computer Science San Jose State University Fall 2013 Instructor: Ron Mak www.cs.sjsu.edu/~mak.

Slides:



Advertisements
Similar presentations
Design Patterns Pepper. Find Patterns Gang of Four created 23 Siemens published another good set x
Advertisements

Chapter 7 – Object-Oriented Design
CS 174: Web Programming April 28 Class Meeting
L3-1-S1 OO Concepts © M.E. Fayad SJSU -- CMPE Software System Engineering Dr. M.E. Fayad, Professor Computer Engineering Department, Room.
L3-5c-S1 Object Diagrams © M.E. Fayad SJSU -- CmpE Software System Engineering Dr. M.E. Fayad, Professor Computer Engineering Department,
Event Handling Events and Listeners Timers and Animation.
L16-S1 Object Diagrams 2003 SJSU -- CmpE Software Patterns Dr. M.E. Fayad, Professor Computer Engineering Department, Room #283I College of Engineering.
L3-5d-S1 Class Diagrams © M.E. Fayad SJSU -- CmpE Software System Engineering Dr. M.E. Fayad, Professor Computer Engineering Department, Room.
Chapter Day 10. © 2007 Pearson Addison-Wesley. All rights reserved4-2 Agenda Day 10 Questions from last Class?? Problem set 2 posted  10 programs from.
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.
Winter 2007ACS-3913 Ron McFadyen1 Observer Pattern Problem: There are many objects (observers / subscribers) needing to know of the state changes, or events,
L5-S1 Class Diagrams 2003 SJSU -- CmpE Software Patterns Dr. M.E. Fayad, Professor Computer Engineering Department, Room #283I College of Engineering San.
Object-Oriented Analysis and Design
Design patterns Observer,Strategi, Composite,Template (Chap 5, 6)
1 Object Oriented Design & Patterns Part 1. 2 Design Patterns Derived from architectural patterns: –rules for design of buildings –describe common problems,
Chapter Day 9. © 2007 Pearson Addison-Wesley. All rights reserved4-2 Agenda Day 8 Questions from last Class?? Problem set 2 posted  10 programs from.
Networking with Java CSc 335 Object-Oriented Programming and Design Spring 2009.
Design Patterns and Graphical User Interfaces Horstmann ,
MVC and MVP. References enter.html enter.html
An Introduction to Software Architecture
CS 160: Software Engineering October 8 Class Meeting
CS 151: Object-Oriented Design October 3 Class Meeting Department of Computer Science San Jose State University Fall 2013 Instructor: Ron Mak
CS 160: Software Engineering September 10 Class Meeting Department of Computer Science San Jose State University Fall 2014 Instructor: Ron Mak
Java Swing, Events and MVC Optional Readings: Eckel’s Thinking in Java: Chap 14 (
Software Design The Dynamic Model Design Sequence Diagrams and Communication Diagrams Instructor: Dr. Hany H. Ammar Dept. of Computer Science and Electrical.
CSC 211 Introduction to Design Patterns. Intro to the course Syllabus About the textbook – Read the introduction and Chapter 1 Good attendance is the.
CS 46B: Introduction to Data Structures June 16 Class Meeting Department of Computer Science San Jose State University Summer 2015 Instructor: Ron Mak.
CS 151: Object-Oriented Design September 24 Class Meeting Department of Computer Science San Jose State University Fall 2013 Instructor: Ron Mak
Course Overview & Topics CSc 335: Object-Oriented Programming and Design © Rick Mercer 1.
CS 235: User Interface Design September 22 Class Meeting Department of Computer Science San Jose State University Fall 2014 Instructor: Ron Mak
CS 160: Software Engineering October 15 Class Meeting
1-1 C Sc 335 Course Overview Object-Oriented Programming and Design Rick Mercer.
Ch 3-4: GUI Basics Java Software Solutions Foundations of Program Design Sixth Edition by Lewis & Loftus Coming up: GUI Components.
CS 151: Object-Oriented Design October 24 Class Meeting Department of Computer Science San Jose State University Fall 2013 Instructor: Ron Mak
CS 151: Object-Oriented Design September 26 Class Meeting Department of Computer Science San Jose State University Fall 2013 Instructor: Ron Mak
CS 153: Concepts of Compiler Design August 26 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
Object-Oriented Analysis and Design. Lesson 1: Introduction to Software Engineering.
1 CSC 222: Object-Oriented Programming Spring 2012 netBeans & GUIBuilder  netBeans IDE create/edit/run a project  GUIBuilder JFrame, JButton, JTextField,
CS 772: Global Knowledge Networks V. “Juggy” Jagannathan CSEE, West Virginia University.
CS 151: Object-Oriented Design September 5 Class Meeting Department of Computer Science San Jose State University Spring 2013 Instructor: Ron Mak
CS 151: Object-Oriented Design September 12 Class Meeting Department of Computer Science San Jose State University Fall 2013 Instructor: Ron Mak
CS 160: Software Engineering October 22 Class Meeting Department of Computer Science San Jose State University Fall 2014 Instructor: Ron Mak
CSC 480 Software Engineering Design With Patterns.
CS 151: Object-Oriented Design October 31 Class Meeting Department of Computer Science San Jose State University Fall 2013 Instructor: Ron Mak
CS 174: Web Programming October 14 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
CS 151: Object-Oriented Design August 29 Class Meeting Department of Computer Science San Jose State University Spring 2012 Instructor: Ron Mak
CS 151: Object-Oriented Design November 5 Class Meeting Department of Computer Science San Jose State University Fall 2013 Instructor: Ron Mak
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.
CS 151: Object-Oriented Design October 1 Class Meeting Department of Computer Science San Jose State University Fall 2013 Instructor: Ron Mak
CS 151: Object-Oriented Design October 29 Class Meeting Department of Computer Science San Jose State University Fall 2013 Instructor: Ron Mak
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.
CS 235: User Interface Design March 17 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
CS 160 and CMPE/SE 131 Software Engineering February 25 Class Meeting Department of Computer Science Department of Computer Engineering San José State.
CS 151: Object-Oriented Design December 3 Class Meeting Department of Computer Science San Jose State University Fall 2013 Instructor: Ron Mak
Software Design Refinement Using Design Patterns
UML Diagrams: Class Diagrams The Static Analysis Model
CMPE 280 Web UI Design and Development August 29 Class Meeting
CS 153: Concepts of Compiler Design August 29 Class Meeting
Observer Design Pattern
CMPE 135: Object-Oriented Analysis and Design October 24 Class Meeting
CS 153: Concepts of Compiler Design November 30 Class Meeting
CSC 480 Software Engineering
CMPE 152: Compiler Design August 23 Class Meeting
CMPE 135: Object-Oriented Analysis and Design December 6 Class Meeting
CMPE 135 Object-Oriented Analysis and Design March 21 Class Meeting
CSC 480 Software Engineering
CMPE 135 Object-Oriented Analysis and Design March 7 Class Meeting
CS 151: Object-Oriented Design October 8 Class Meeting
Presentation transcript:

CS 151: Object-Oriented Design October 15 Class Meeting Department of Computer Science San Jose State University Fall 2013 Instructor: Ron Mak

SJSU Dept. of Computer Science Fall 2013: October 15 CS 151: Object-Oriented Design © R. Mak 2 In-Class Team Exercise: UML Class Diagram  Draw a UML class diagram that captures all of these facts: A university has several departments. Each department has a department chair. Each department teaches several courses. Two of the departments are computer science (CS) and computer engineering (CMPE). The computer science department teaches the courses CS 101, CS 102, and CS 103. The computer engineering department teaches the courses CMPE 101 and CMPE 102. CS 102, CS 103, and CMPE 102 are also online. Each course has a professor, a number of students, and possibly a graduate student T.A. People have home addresses.

SJSU Dept. of Computer Science Fall 2013: October 15 CS 151: Object-Oriented Design © R. Mak 3 An Exercise Solution University Address Chair «interface» Graduate Person CS 101 CS 102 CS 103 CMPE 101 CMPE 102 Computer Engineering Computer Science Department 1..n Course 1..n Student Professor 1..n TA 0..1 «interface» Online

SJSU Dept. of Computer Science Fall 2013: October 15 CS 151: Object-Oriented Design © R. Mak 4 What Lessons Did We Learn?  “Factor out” common properties and put them into superclasses. Examples: Department, Course, Person Many of these classes should be abstract (not shown in the suggested solution). But not all: Student  Use marker interfaces to “tag” certain classes that are in different hierarchies. Examples: Online, Graduate  “May have” or “possibly have” means the multiplicity starts with 0. Example: A course possibly has a TA.

SJSU Dept. of Computer Science Fall 2013: October 15 CS 151: Object-Oriented Design © R. Mak 5 Review: Model-View-Controller Architecture  The user interacts with the controller (via buttons, menus, etc.) to send it commands.  The commands may tell the controller to modify the view directly, or the controller may alter the state of the model.  The altered model causes the view to update how it displays the model’s data.  The user reacts to changes in the view by interacting with the controller to send it new commands. _ The user never manipulates the model directly, only through the controller.

SJSU Dept. of Computer Science Fall 2013: October 15 CS 151: Object-Oriented Design © R. Mak 6 Model-View-Controller Example alter state update CONTROLLER MODEL VIEW #1VIEW #2 User send command  There can be multiple views of the same model. Each view updates after the model changes.

SJSU Dept. of Computer Science Fall 2013: October 15 CS 151: Object-Oriented Design © R. Mak 7 The Observer Design Pattern  Context An object (the “subject”) generates “events”. One or more other objects (the “observers”) want to be notified whenever an event occurs.  Solution The subject manages (attaches and detaches) a collection of observer objects. Each observer object is instantiated from a class that implements the Observer interface. Whenever an event occurs, the subject object notifies each observer object by calling the notify() interface method. From: Object-Oriented Design & Patterns, John Wiley & Sons, 2006.

SJSU Dept. of Computer Science Fall 2013: October 15 CS 151: Object-Oriented Design © R. Mak 8 The Observer Design Pattern  Therefore, in the MVC architecture, each time the model object (subject) changes (an event), it notifies each of its view objects (observers).  Where have we already seen another example of the observer design pattern? What happens when you click a button in a GUI? The actionPerformed() method of each ActionListener object that is attached to the button is called. What are the subject, event, observer, and notification method?  Subject = button Event = button click Observer = action listener Notify method = actionPerformed()

SJSU Dept. of Computer Science Fall 2013: October 15 CS 151: Object-Oriented Design © R. Mak 9 Quiz #4 2013Oct15

SJSU Dept. of Computer Science Fall 2013: October 15 CS 151: Object-Oriented Design © R. Mak 10 Review for the Midterm  What it means for software to be well-designed.  Achieving good design via an iterative process.  Encapsulate parts of the design that will change. Refactoring.  Iterative and incremental development. Mini-waterfall per iteration.  Functional specification Functional requirements Nonfunctional requirements Stated and implied requirements

SJSU Dept. of Computer Science Fall 2013: October 15 CS 151: Object-Oriented Design © R. Mak 11 Review for the Midterm  Use cases UML use case diagram Use case description  Where do classes come from?  Class responsibilities and relationships CRC cards _

SJSU Dept. of Computer Science Fall 2013: October 15 CS 151: Object-Oriented Design © R. Mak 12 Review for the Midterm  UML class diagram Relationships Multiplicities Aggregation vs. composition  UML sequence diagram  UML state diagram _

SJSU Dept. of Computer Science Fall 2013: October 15 CS 151: Object-Oriented Design © R. Mak 13 Review for the Midterm  Javadoc  Designing good classes Example: Day class  Factory method design pattern  Importance of encapsulation _

SJSU Dept. of Computer Science Fall 2013: October 15 CS 151: Object-Oriented Design © R. Mak 14 Review for the Midterm  Accessors and mutators  Side effects  Mutable and immutable classes Final fields  How good is an interface? _

SJSU Dept. of Computer Science Fall 2013: October 15 CS 151: Object-Oriented Design © R. Mak 15 Review for the Midterm  Programming by contract Preconditions Postconditions Invariants Assertions  Unit testing JUnit  Regression testing  Design patterns _

SJSU Dept. of Computer Science Fall 2013: October 15 CS 151: Object-Oriented Design © R. Mak 16 Review for the Midterm  Coding to the interface  Java interfaces Marker interfaces  Polymorphism  Comparable interface type  Comparator interface type  Anonymous classes _

SJSU Dept. of Computer Science Fall 2013: October 15 CS 151: Object-Oriented Design © R. Mak 17 Review for the Midterm  JFrame class  JButton class  JTextField class  Button actions _

SJSU Dept. of Computer Science Fall 2013: October 15 CS 151: Object-Oriented Design © R. Mak 18 Review for the Midterm  Inversion of control  Java Timer class  Graphics context Shape interface Animation  Interface as a contract  Strategy design pattern  Dynamic class loading

SJSU Dept. of Computer Science Fall 2013: October 15 CS 151: Object-Oriented Design © R. Mak 19 Review for the Midterm  Swing development support in NetBeans  Model-view-controller architecture  Observer design pattern _