MIDTERM REVIEW. Abstraction Functions Internal (like the representation invariant) Client doesn’t need this! Can be used to show code correctness when.

Slides:



Advertisements
Similar presentations
Data Abstraction II SWE 619 Software Construction Last Modified, Spring 2009 Paul Ammann.
Advertisements

CSE 331 SOFTWARE DESIGN & IMPLEMENTATION ABSTRACT DATA TYPES II Autumn 2011.
Abstraction Functions. Announcements Exam 1 on Tuesday March 3 rd Closed book/phone/laptop 2 cheat pages allowed (handwritten or typed) 1 double-sided.
Specifications Liskov Chapter 9 SWE 619 Last Updated Fall 2008.
Computer Science 340 Software Design & Testing Design By Contract.
Procedure specifications CSE 331. Outline Satisfying a specification; substitutability Stronger and weaker specifications - Comparing by hand - Comparing.
Cs2220: Engineering Software Class 8: Implementing Data Abstractions Fall 2010 University of Virginia David Evans.
1 Abstraction  Identify important aspects and ignore the details  Permeates software development programming languages are abstractions built on hardware.
Cs205: engineering software university of virginia fall 2006 Data Abstraction David Evans
23-Oct-15 Abstract Data Types. 2 Data types A data type is characterized by: a set of values a data representation, which is common to all these values,
LinkedList Many slides from Horstmann modified by Dr V.
Penny Nickel Dime Penny Nickel Dime Quarter Half Dollar.
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
Counting Coins. The Basics Quarter 25 cents Dime 10 cents.
MONEY! Pick the correct coin! Click here to get started!!
Let’s Learn About Money!
Name the United States Coins Count the Pennies 10 ¢
(c) University of Washington15-1 CSC 143 Java List Implementation via Arrays Reading: 13.
CSC 480 Software Engineering Design by Contract. Detail Design Road Map Begin with architectural models  Class model: domain classes  Overall state.
Type Abstraction Liskov, Chapter 7. 2 Liskov Substitution Principle In any client code, if the supertype object is substituted by a subtype object, the.
Data Abstractions EECE 310: Software Engineering.
CSE 331 Software Design & Implementation Hal Perkins Autumn 2012 Abstract Data Types – Examples / Summary (Based on slides by Mike Ernst and David Notkin)
Adding and Subtracting Money! Click on the dollar sign to begin!
Data Abstraction SWE 619 Software Construction Last Modified, Spring 2009 Paul Ammann.
SWE 4743 Abstract Data Types Richard Gesick. SWE Abstract Data Types Object-oriented design is based on the theory of abstract data types Domain.
Understanding ADTs CSE 331 University of Washington.
Representation invariants and abstraction functions CSE 331 UW CSE.
CSE 331 Software Design & Implementation Dan Grossman Fall 2014 Abstraction Functions (Based on slides by Mike Ernst, David Notkin, Hal Perkins)
CSE 331 SOFTWARE DESIGN & IMPLEMENTATION ABSTRACT DATA TYPES Autumn 2011.
Slides with material from Alex Mariakakis, Krysta Yousoufian, Mike Ernst, Kellen Donohue Section 3: HW4, ADTs, and more.
David Evans CS201J: Engineering Software University of Virginia Computer Science Lecture 7: A Tale of Two Graphs (and.
CSC 243 – Java Programming, Spring, 2014 Week 4, Interfaces, Derived Classes, and Abstract Classes.
David Evans CS201J: Engineering Software University of Virginia Computer Science Lecture 5: Implementing Data Abstractions.
Zach Tatlock / Winter 2016 CSE 331 Software Design and Implementation Lecture 6 Representation Invariants.
Representation Invariants and Abstraction Functions.
Reasoning and Design (and Assertions). How to Design Your Code The hard way: Just start coding. When something doesn’t work, code some more! The easier.
Money – Change Combinations &MathLine. Start with each ring representing a penny Money – Change.
Prof. I. J. Chung Data Structure #1 Professor I. J. Chung.
Slides by Alex Mariakakis Section 5: Midterm Review.
CSE 331 Software Design & Implementation Hal Perkins Autumn 2012 Data Abstraction: Abstract Data Types (ADTs) (Based on slides by Mike Ernst and David.
EECE 310: Software Engineering
CSE 331 Software Design & Implementation
CSE 331 Software Design and Implementation
k-2 Lesson d: kids as coins Coin Signs
Money Concept Assessment Bank
Type Abstraction SWE Spring 2009.
Preconditions precondition: Something your method assumes is true at the start of its execution. Often documented as a comment on the method's header:
Abstraction Functions and Representation Invariants
CSE 331 Software Design and Implementation
CSE 331 Software Design and Implementation
Abstraction functions, Reasoning About ADTs
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $
Exam 1 Review.
Section 6: Midterm Review
Type Abstraction Liskov, Chapter 7.
Data Abstraction David Evans cs205: engineering software
Name the United States Coins
SWE 619 Software Construction Last Modified, Fall 2015 Paul Ammann
Method Verification CS/SWE 332 Paul Ammann.
Lecture 7: A Tale of Two Graphs CS201j: Engineering Software
Lecture 4: Data Abstraction CS201j: Engineering Software
CSE 331 Software Design and Implementation
Warmup ["hip","hip"] = Hip Hip Array! ???.
CSE 331 Software Design & Implementation
CSE 331 Software Design & Implementation
Assertions References: internet notes; Bertrand Meyer, Object-Oriented Software Construction; 4/25/2019.
Money Math Review.
Type Abstraction SWE Spring 2013.
Reasoning about Data Abstractions
Method Verification Paul Ammann.
Presentation transcript:

MIDTERM REVIEW

Abstraction Functions Internal (like the representation invariant) Client doesn’t need this! Can be used to show code correctness when combined with spec and rep invariant Maps concrete representation to abstract value

Abstraction Functions AF: R ⇒ A R: Set of objects Consists of fields in the class; concrete, code A: Set of abstract objects What the object means; abstract, conceptual AF: References internal code representation Can contain calculations, etc that the client doesn’t care about

Abstraction Functions public class Line { private Point start; private Point end; …} // AF(r) = line l such that // l.start = r.start // l.end = r.end

Abstraction Functions /** * Card represents an immutable playing card. suit: {Clubs,Diamonds,Hearts,Spades} value: {Ace,2,...,Jack,Queen,King} */ public class Card { private int index; … } // suit = S(index div 13) // where S(0)=Clubs, S(1)=Diamonds, … // value = V(index mod 13) // where V(1)=Ace, V(2)=2,..., // V(12)=Queen, V(0)=King

Specification strength Stronger specification is: Easier or harder for the client to use? Easier or harder for the implementer to specify? To weaken a specification, you can: Strengthen or weaken the preconditions? Strengthen or weaken the postconditions?

Documentation class IntegerSet { private List set = new LinkedList (); public boolean contains(int x) { int index = set.indexOf(x); if (index != -1) { set.remove(index); set.add(0, x); } return index != @throws?

Backwards Reasoning { (x * y) * y n-1 = b } => { x * y n = b } x = x * y; { x * y n-1 = b } n = n - 1; { x * y n = b }

Forwards Reasoning { |x| > 2 } x = x * 2; { |x| > 4 } x = x – 1; { x > 3 | x < -5 }

CoinPile Class class CoinPile { private List coins; public CoinPile() { coins = new ArrayList (); }... // many more methods for adding and removing coins, computing change, etc. }

CoinPile Class class CoinPile { private List coins; public CoinPile() { coins = new ArrayList (); }... // many more methods for adding and removing coins, computing change, etc. pennies: nickels: dimes: quarters: int Representation invariant? Abstraction function?

CoinPile Class, a list of coins with one coin of value n for each coin in this with value n (i.e., the list of coins in this) public List getCoins() { return new ArrayList (coins); } Representation exposure?