Reasoning about Data Abstractions

Slides:



Advertisements
Similar presentations
Writing specifications for object-oriented programs K. Rustan M. Leino Microsoft Research, Redmond, WA, USA 21 Jan 2005 Invited talk, AIOOL 2005 Paris,
Advertisements

Challenges in increasing tool support for programming K. Rustan M. Leino Microsoft Research, Redmond, WA, USA 23 Sep 2004 ICTAC Guiyang, Guizhou, PRC joint.
Cs2220: Engineering Software Class 10: Generic Datatypes Fall 2010 University of Virginia David Evans.
Composition CMSC 202. Code Reuse Effective software development relies on reusing existing code. Code reuse must be more than just copying code and changing.
David Evans CS201J: Engineering Software University of Virginia Computer Science Lecture 6: Reasoning about Data Abstractions.
Data Abstraction II SWE 619 Software Construction Last Modified, Spring 2009 Paul Ammann.
CSE 331 SOFTWARE DESIGN & IMPLEMENTATION ABSTRACT DATA TYPES II Autumn 2011.
CS 307 Fundamentals of Computer Science 1 Abstract Data Types many slides taken from Mike Scott, UT Austin.
CSE 331 Software Design & Implementation Dan Grossman Fall 2014 Data Abstraction: Abstract Data Types (ADTs) (Based on slides by Mike Ernst, David Notkin,
Cs205: engineering software university of virginia fall 2006 Semantics and Specifying Procedures David Evans
Cs2220: Engineering Software Class 11: Subtyping and Inheritance Fall 2010 University of Virginia David Evans.
REFACTORING Lecture 4. Definition Refactoring is a process of changing the internal structure of the program, not affecting its external behavior and.
Cs2220: Engineering Software Class 8: Implementing Data Abstractions Fall 2010 University of Virginia David Evans.
Chapter 3 List Stacks and Queues. Data Structures Data structure is a representation of data and the operations allowed on that data. Data structure is.
Data Abstraction CS 201j: Engineering Software University of Virginia Computer Science Nathanael Paul
Cs205: engineering software university of virginia fall 2006 Data Abstraction David Evans
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)
Type Abstraction SWE Spring October 05Kaushik, Ammann Substitution Principle “In any client code, if supertype object is substituted.
Polymorphism (generics) CSE 331 University of Washington.
Data Abstraction SWE 619 Software Construction Last Modified, Spring 2009 Paul Ammann.
Understanding ADTs CSE 331 University of Washington.
Representation invariants and abstraction functions CSE 331 UW CSE.
David Evans CS201j: Engineering Software University of Virginia Computer Science Lecture 9: Designing Exceptionally.
CSE 331 Software Design & Implementation Dan Grossman Fall 2014 Abstraction Functions (Based on slides by Mike Ernst, David Notkin, Hal Perkins)
Cs2220: Engineering Software Class 12: Substitution Principle Fall 2010 University of Virginia David Evans.
It is better to have 100 functions operate on one data structure than 10 functions on 10 data structures. Alan Perlis Lecture 15: Data Abstraction.
Fusion Design Overview Object Interaction Graph Visibility Graph Class Descriptions Inheritance Graphs Fusion: Design The overall goal of Design is to.
CSE 331 SOFTWARE DESIGN & IMPLEMENTATION ABSTRACT DATA TYPES Autumn 2011.
David Evans CS201j: Engineering Software University of Virginia Computer Science Lecture 10: Programming Exceptionally.
David Evans CS201j: Engineering Software University of Virginia Computer Science Lecture 11: Subtyping and Inheritance.
Cs205: engineering software university of virginia fall 2006 Programming Exceptionally David Evans
David Evans CS201J: Engineering Software University of Virginia Computer Science Lecture 7: A Tale of Two Graphs (and.
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.
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.
EECE 310: Software Engineering
Design Class Diagrams
Design David Evans cs205: engineering software
CSE 331 Software Design & Implementation
CSE 331 Software Design & Implementation
CSE 331 Software Design and Implementation
Type Abstraction SWE Spring 2009.
CSE 331 Software Design and Implementation
CSE 331 Software Design and Implementation
Concurring Concurrently
Abstraction functions, Reasoning About ADTs
CSE 331 Software Design & Implementation
Type Abstraction Liskov, Chapter 7.
CSE 331 Software Design and Implementation
Lecture 5: Code Red, Ariane 5, and Gambling
Data Abstraction David Evans cs205: engineering software
CSE 331 Software Design & Implementation
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
Lecture 7: Data Abstraction
CSE 331 Software Design & Implementation
EECE 310: Software Engineering
CSE 331 Software Design and Implementation
CSE 331 Software Design & Implementation
CSE 331 Software Design & Implementation
Lecture 13: Subtyping Rules Killer Bear Climber
Lecture 15: Quicker Sorting CS150: Computer Science
CSE 331 Software Design & Implementation
Type Abstraction SWE Spring 2013.
Method Verification Paul Ammann.
Presentation transcript:

Reasoning about Data Abstractions cs205: engineering software university of virginia fall 2006 Reasoning about Data Abstractions Quiz 2 is postponed and will be in class Friday. It will cover Data Abstraction including rep invariants and abstraction functions. David Evans www.cs.virginia.edu/cs205

To Reason about Operations What values of the concrete rep are valid: Representation Invariant I: C → boolean Prove all objects satisfy the invariant before leaving the implementation code Assume all objects passed in satisfy the invariant How the concrete rep maps to abstract values: Abstraction Function

Abstraction Function The Abstraction Function maps a concrete state to an abstract state: AF: C → A Function from concrete representation to the abstract notation introduced in overview specification. What is the range of the Abstraction Function? Range is concrete states for which rep invariant is true

Abstraction Function for Set public class Set<T> { // OVERVIEW: Sets are unbounded, // mutable sets of objects of type T. // A typical Set is {x1, ..., xn} // Representation: private Vector<T> rep; // AF (c) = // { AFT (c.rep.elementAt(i)) | 0 <= i < c.rep.size () }

Correctness of Insert public void insert (String s) { // MODIFIES: this // EFFECTS: Adds s to the elements of this: // this_post = this_pre U { s } if (!contains (s)) { rep.add (s); } } Use abstraction function to show if add implements its specification, then AF(rep_post) = AF(rep_pre) U {AFString(s)}

Reality Check Writing abstraction functions, rep invariants, testing code thoroughly, reasoning about correctness, etc. for a big program is a ridiculous amount of work! Does anyone really do this? Yes (and a lot more), but usually only when its really important to get things right: Cost per line of code: Small, unimportant projects: $1-5/line WindowsNT: about $100/line FAA’s Automation System (1982-1994): $900/line

Rest of Today Graph datatype from notes (very similar but not identical to PS3 datatype!) Decide on a representation and its rep invariant and abstraction function Think about how different methods would be implemented