EECS 280 Lecture 7: EECS 280 Lecture 7 – Abstract Data Types in C

72 views3 pages

For unlimited access to Class Notes, a Class+ subscription is required.

Lecture 7 Abstract Data Types in C
Recall: Procedural Abstraction
o Procedural abstraction separates what code does from how it works
o We separate the interface from the implementation
Abstract Data Types (ADTs)
o We can also use data abstraction to separate what a type is from how it works
o Separate interface from implementation
o EX: We a still use stigs ee though e do’t ko all the ie okigs of
how they are implemented
C-Style ADTs (structs)
o Use a struct to represent the data
o Define functions for Triangle behaviors
The first parameter is a pointer to the triangle struct we want to work
with
o Define an initializer function to check the values used to initialize the Triangle
member variables
Representation Invariants
o A problem for compound types
“oe oiatio of ee alues do’t ake sese togethe
o We use representation invariants to express the conditions for a valid compound
object
Representation vs Abstraction
o We pick some way to represent our abstract concept with data (e.g. 3 doubles)
o Only some possible values in the representation are valid (meaningful in the
abstraction)
C-Style ADTs (structs)
o Check invariants using asserts (project 2)
o Other representations are possible
Different representation invariants
RESPECT THE INTERFACE!!!
Plain Old Data
o A simple compound type where the interface and implementation are the same
Abstraction Layers
o ADTs can be composed to provide multiple layers of abstraction
Types of Test Cases
o Type pohiited DON’T
o Reuies pohiited DON’T
o Simple
o (Edge) Special
o Stress (not needed for P3)
Test-Driven Development
o First write test for desired behavior
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows page 1 of the document.
Unlock all 3 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+
$10 USD/m
Billed $120 USD annually
Homework Help
Class Notes
Textbook Notes
40 Verified Answers
Study Guides
1 Booster Class
Class+
$8 USD/m
Billed $96 USD annually
Homework Help
Class Notes
Textbook Notes
30 Verified Answers
Study Guides
1 Booster Class