15-subtypes-subclasses

15-subtypes-subclasses - Last Time: * Midterm Today: *...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 Last Time: * Midterm Today: * Subtypes: the substitution principle * Three possible subtype refinements: * Created a subtype of IntSet: MaxIntSet * Subtyping by overriding a method * Subclassing but not subtyping * Apparent vs. Actual types * Static vs. Dynamic information * Return midterms +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Midterm recap: High: 97 Low: 6 Median: 52 Mean: 52.2 StDev: 19.9 In hindsight, it seems to us that (a) the exam was a little harder than we expected, and (b) the grading was a little stricter than it necessarily needed to be. We do have high standards for you, so that is worth keeping in mind for the final exam. But, remember that it's all relative, so this isn't an inidication that you are all "doing poorly", or anything of the sort! I'll return exams at the end of class, but here are a few points of context: * The median student can expect something in a low B or a high B-. * Anyone with a 33 or better is doing fine, presuming that other grades are also sufficient. * Anyone between 23 and 32 needs to think about how to improve. * Anyone below 23 should to come speak with us about how we can help, and what your options are. We will go over the correct answers in discussion section this week. Please don't come to us with questions about the exam until after you have been to discussion---we want to devote available office hour time to Project 3. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ We've talked a lot about types in class. Today, we'll add a new
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Sheet1 Page 2 notion to our understanding of types: the "subtype". Suppose we have two types, S and T. We say that "S is a subtype of T", written "S <: T" if, for any instance where an object of type T is expected, an object of type S can be supplied without changing the correctness of the original computation. or If "S is a subtype of T" then objects of type T may be replaced with objects of type S without altering any of the desirable properties of that program (correctness) This is called the "substitution principle". It was first described in a paper written by Barbara Liskov and Jeannette Wing. Prof. Liskov is a chaired Professor at MIT. Prof. Wing was a student of Prof. Liskov's, and is currently the Director of Computatoinal and Information Science and Engineering at the National Science Foundation. If S <: T then we also say that "T is a supertype of S". Subtypes are different from the notion of "type-convertible". For example, in any computation that expects a double, you can use an int. However, the object isn't an int when it is used---it is first converted to a double---it's physical representation changes. However, if you use a (reference to a) subtype where a (reference to a) supertype is expected, it is not converted to the supertype---instead, it is used as-is. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ In an ADT, there are three ways to create a subtype from a supertype:
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 22

15-subtypes-subclasses - Last Time: * Midterm Today: *...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online