Exam Review. CSE 331 Section 10 12/6/12. Slides by Kellen Donohue with material from Mike Ernst

Similar documents
Announcements. Lecture 15 Generics 2. Announcements. Big picture. CSE 331 Software Design and Implementation

CSE 331 Software Design and Implementation. Lecture 15 Generics 2

CSE 331 Software Design and Implementation. Lecture 14 Generics 2

CSE 331 Software Design and Implementation. Lecture 14 Generics 2

CSE 331 Software Design & Implementation

Exam 2. Topics. Preconditions vs. Exceptions. Exam 2 Review. Exam 2 on Thursday, March 29 th. Closed book, closed computer, closed phone

CSE 331. Generics (Parametric Polymorphism)

CSE 331 Final Exam 6/5/17. Name UW ID#

Lecture Outline. Parametric Polymorphism and Java Generics. Polymorphism. Polymorphism

CSE331 Spring 2015, Final Examination June 8, 2015

CSE 331 Software Design & Implementation

CSE wi Final Exam 3/12/18 Sample Solution

CSE wi Final Exam 3/12/18. Name UW ID#

CSE 331 Final Exam 6/5/17 Sample Solution

CSE 331 Midterm Exam 2/13/12

Top Down Design vs. Modularization

CSE 331 Final Exam 12/14/15 Sample Solution. Question 1. (20 points, 1 each) Warmup. For each statement, circle T if it is true and F if it is false.

CSE 331 Software Design & Implementation

Parametric polymorphism and Generics

CSE 331 Midterm Exam Sample Solution 2/18/15

Stronger vs Weaker (one more time!) Requires more? Promises more? (stricter specifications on what the effects entail)

CS 215 Software Design Homework 3 Due: February 28, 11:30 PM

CSE 331 Final Exam 3/16/15 Sample Solution

CSE 331 Final Exam 6/10/14

CSE331 Winter 2014, Final Examination March 17, 2014 Please do not turn the page until 8:30. Rules:

Introduction to Programming System Design CSCI 455x (4 Units)

Section 10 MATERIAL PULLED FROM LAST SECTION AND LAST YEAR S SLIDES

340 Review Fall Midterm 1 Review

CSE 331 Midterm Exam Sample Solution 2/13/12

Program Verification using Templates over Predicate Abstraction. Saurabh Srivastava and Sumit Gulwani

CSE wi Midterm Exam 2/8/18. Name UW ID #

Java for Non Majors. Final Study Guide. April 26, You will have an opportunity to earn 20 extra credit points.

CS61B Lecture #25: Java Generics. Last modified: Thu Oct 19 19:36: CS61B: Lecture #25 1

CSE331 Autumn 2011 Midterm Examination October 28, 2011

CS61B Lecture #24. Today: Java support for generic programming. Readings for today: A Java Reference, Chapter 10.

hw6, BFS, debugging CSE 331 Section 5 10/25/12 Slides by Kellen Donohue

CS61B Lecture #25: Java Generics. Last modified: Thu Oct 18 21:04: CS61B: Lecture #25 1

CSE wi Midterm Exam 2/8/18 Sample Solution

Polymorphism (generics)

CSE331 Winter 2014, Midterm Examination February 12, 2014

Announcements. Lecture 14 Generics 1. Announcements. CSE 331 Software Design and Implementation. Leah Perlmutter / Summer 2018

CSE 331 Software Design and Implementation. Lecture 14 Generics 1

CSE 331 Final Exam 3/12/12

CSE 331 Final Exam 12/9/13

CS61B Lecture #23. Today: Java support for generic programming. Readings for today: A Java Reference, Chapter 10.

CSE 331 Summer 2017 Final Exam. The exam is closed book and closed electronics. One page of notes is allowed.

CSE 331 Final Exam 6/7/16

CS 315 Software Design Homework 3 Preconditions, Postconditions, Invariants Due: Sept. 29, 11:30 PM

Announcements. Java Graphics. Exceptions. Java Odds & Ends

CSE 331 Software Design & Implementation

Lecture 24 Wrap Up. Final Logistics CSE 331. Today. CSE 331 Software Design and Implementation. Wednesday, 8:30-10:20 AM

CSE 331 Software Design and Implementation. Lecture 24 Wrap Up

Announcements. Testing. Announcements. Announcements

CSE 331 Final Exam 6/7/16 Sample Solution

CSE 331 Midterm Exam 11/9/15 Sample Solution

CSE 331 Software Design and Implementation. Lecture 4 Specifications

Announcements. Written Assignment 2 due today at 5:00PM. Programming Project 2 due Friday at 11:59PM. Please contact us with questions!

Testing and Debugging

CSE331 Winter 2014, Midterm Examination February 12, 2014

CSE 331 Final Exam 3/18/13

CSE 374 Programming Concepts & Tools. Hal Perkins Fall 2015 Lecture 15 Testing

Final Exam. Final Exam Review. Ch 1: Introduction: Object-oriented analysis, design, implementation. Exam Format

CSE 331 Spring 2018 Midterm

Week Chapter Assignment SD Technology Standards. 1,2, Review Knowledge Check JP3.1. Program 5.1. Program 5.1. Program 5.2. Program 5.2. Program 5.

Lecture 4 Specifications

CSE 331 Software Design and Implementation. Lecture 13 Generics 1

Code verification. CSE 331 University of Washington. Michael Ernst

JAVA V Source files Java, winter semester

Java Generics. Lecture CS1122 Summer 2008

University of Washington CSE 331 Software Design & Implementation Spring Final exam. Monday, June 10, 2013

public static void negate2(list<integer> t)

Announcements. Subtype Polymorphism, Subtyping vs. Subclassing, Liskov Substitution Principle. Intuition: Type Signature is a Specification.

Implementing Hash and AVL

public class Test { public static int i = 0;

CS108, Stanford Handout #8. Java Generics

CSE 143: Computer Programming II Spring 2015 HW7: 20 Questions (due Thursday, May 28, :30pm)

CSE 331 Software Design & Implementation

Reasoning about programs

Last time. Reasoning about programs. Coming up. Project Final Presentations. This Thursday, Nov 30: 4 th in-class exercise

CSE 331 Winter 2016 Midterm Solution

CIS 121 Data Structures and Algorithms with Java Spring 2018

Outline. Logistics. Logistics. Principles of Software (CSCI 2600) Spring Logistics csci2600/

CS 201 Advanced Object-Oriented Programming Lab 6 - Sudoku, Part 2 Due: March 10/11, 11:30 PM

Check out FilesAndExceptions from SVN. Exam 2 Review File I/O, Exceptions Vector Graphics Project

Object Oriented Programming: In this course we began an introduction to programming from an object-oriented approach.

Assertions. Assertions - Example

Generics עזאם מרעי המחלקה למדעי המחשב אוניברסיטת בן-גוריון

Testing and Debugging

Dartmouth College Computer Science 10, Winter 2012 Final Exam

COMP6700/2140 Generic Methods

CSE331 Autumn 2011 Final Examination December 14, 2011

Java 5 New Language Features

Program Correctness and Efficiency. Chapter 2

MIDTERM EXAM THURSDAY MARCH

CSC207 Week 4. Larry Zhang

a. The following method would allow an object of the static type List<String> to be passed to it as an argument.

Foundations of object orientation

INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad

Section 8: Design Patterns. Slides by Alex Mariakakis. with material from David Mailhot, Hal Perkins, Mike Ernst

EINDHOVEN UNIVERSITY OF TECHNOLOGY

Transcription:

Exam Review CSE 331 Section 10 12/6/12 Slides by Kellen Donohue with material from Mike Ernst

Course Logistics All homework s done (except late days) HW8 returned HW7 being graded HW9 will be graded during finals week Final on Monday Review session Sunday, 3PM in our normal classroom

Final Exam 8:30 AM Full final (vs. some previous quarters) Cumulative over the quarter All section and lecture material May include project-related questions

Reasoning about code Forward reasoning Backward reasoning Finding the weakest precondition If/else reasoning Loop development Loop invariant True before loop, re-established at end of each loop Practice: Do the problems from hw1 and hw2 again, google practice interview questions, answer and prove

Specifications Stronger vs. weaker specs. How to prove Strong/weaker pre/post conditions One implementation satisfies another Effect on client/implementer Javadoc -- requires, effects, modifies, etc. Practice: Review old midterms and finals

Daikon invariant detection Tool for automatically generating specifications Daikon uses a compiler front-end (not like a GUI front-end) to add instrumentation calls to your program At beginning and end of every method Says what the value of every variable is Running your program produces a program trace

Daikon Datatrace HelloWorld.ArrayHolder.updateArray(System.Int32[]\_integers):::ENTER this_invocation_nonce 2 this 4094363 1 this.basearray 63208015 1 this.basearray[..] [] 1 this.expandedarray 41962596 1 this.expandedarray[..] [] 1 this.gettype() "HelloWorld.ArrayHolder" 1 integers 43527150 1 integers[..] [-1 0 1] 1 HelloWorld.ArrayHolder.updateArray(System.Int32[]\_integers):::EXIT66 this_invocation_nonce 2 this 4094363 1 this.basearray 63208015 1 this.basearray[..] [4 5 6] 1 this.expandedarray 41962596 1 this.expandedarray[..] [3 4 5 6 7] 1

Daikon Invariants Daikon then analyzes the data trace and guesses invariants using machine learning this.a > abs(y) array a is sorted n.left.value < n.right.value p!= null p.content in myarray x = orig(x+1) Invariants can be encoded in the program with asserts, javadoc, etc. False positives can be removed by adding new tests

Abstract Data Types (ADT s) Abstraction vs. implementation/representation Representation Invariant Abstraction function Representation exposure Practice: Think about implementing a sample ADT, a PriorityQueue is a good example, write an AF and RI. Change implementation details and update the AF and RI.

Testing Theory Unit testing vs. other kinds Black box vs. white box Implementation vs. specification Revealing subdomains Boundary cases Coverage types Practice: Think about how you would test projects that you didn t already write tests for (other CSE classes)

Testing Practice JUnit basics Test rules of thumb Test only one function at a time if possible Test only one data set per test Use at least one assert per test More in section slides Practice: Implement JUnit tests for projects that you didn t already write tests for (other CSE classes)

Interfaces & Classes Specification, how to comment Classes & Types Coupling/Cohesion Including the right amount Avoid god classes Avoid writing a kitchen sink class Practice: Design the data model for a smartphone contacts application

Exceptions and assertions Rationale behind exceptions Basic Uses Exception vs. assertions Checked vs. unchecked exceptions Special values vs. exceptions

Debugging strategies Setting up experiments Use with testing Regression testing Binary search

Identity & Equality Properties of equality Reference equality hashcode() and equals()

Subtypes & Subclasses True subtypes vs. Java subtypes Remember the Properties class that extends Hashtable but isn t a true subtype Composition/delegation vs. inheritance Remember InstrumentedHashSet problems with inheritance Interfaces & abstract classes

Generics Use generic, not raw collections Remember generic data is erased at runtime Java subtyping is invariant subtyping This is more restrictive than we want, (e.g. can t call a method taking List<Object> with a List<Integer>) so commonly use wildcards

Wildcards? indicates a wild-card type parameter, one that can be any type List<?> list = new List<?>(); // anything Difference between List<?> and List<Object>? can become any particular type; Object is just one such type List<Object> is restrictive; wouldn't take a List<String> Wildcards can be bounded with extends of super Difference between List<Foo> and List<? extends Foo> The latter binds to a particular Foo subtype and allows ONLY that Ex: List<? extends Animal> might store only Giraffes but not Zebras The former allows anything that is a subtype of Foo in the same list Ex: List<Animal> could store both Giraffes and Zebras 18

PECS: Producer Extends, Consumer Super Where should you insert wildcards? Should you use extends or super or neither? Use? extends T when you get values from a producer Use? super T when you put values into a consumer Use neither (just T, not?) if you do both <T> void copy( List<? super T> dst, List<? extends T> src) 19

Legal operations on wildcard types Object o; Number n; Integer i; PositiveInteger p; List<? extends Integer> lei; First, which of these is legal? lei = new ArrayList<Object>; lei = new ArrayList<Number>; lei = new ArrayList<Integer>; lei = new ArrayList<PositiveInteger>; lei = new ArrayList<NegativeInteger>; Which of these is legal? lei.add(o); lei.add(n); lei.add(i); lei.add(p); lei.add(null); o = lei.get(0); n = lei.get(0); i = lei.get(0); p = lei.get(0);

Legal operations on wildcard types Object o; Number n; Integer i; PositiveInteger p; List<? super Integer> lsi; First, which of these is legal? lsi = new ArrayList<Object>; lsi = new ArrayList<Number>; lsi = new ArrayList<Integer>; lsi = new ArrayList<PositiveInteger>; lsi = new ArrayList<NegativeInteger>; Which of these is legal? lsi.add(o); lsi.add(n); lsi.add(i); lsi.add(p); lsi.add(null); o = lsi.get(0); n = lsi.get(0); i = lsi.get(0); p = lsi.get(0);

Events, listeners, and callbacks Register to be called back when an event occurs Useful for inverting dependency Review the Observer pattern

MVC Model covers everything related to loading, managing the data, performing computations, etc. View shows the model to the user in one of many ways (may use Observer pattern to be notified of updates) Controllers are how the user interacts with the data and customizes the view Practice: Design views and controllers for earlier Contacts app

Design Patterns Need & purpose Creational Patterns Singleton Interning Factory Structural Patterns Adaptor Proxy Behavioral Patterns Composite Visitor Know what patterns are useful for

Swing GUI Usability Swing vs. AWT JFrame & JPanel for layout Using paintcomponent() for drawing Interaction with Events, Listeners Practice: Implement earlier Contacts app

System integration Architecture Tools Source control Bug tracking Schedule Potential problems How to deal with slippage Implementation / test order Top-down or bottom-up Test drivers or stubs Pros and cons of each

Final Topics Reasoning Specifications ADTs Testing Class design Exceptions & assertions Debugging Identity & equality Generics Events, callbacks MVC Design patterns Swing GUIs System Integration

Course Evals