CSC153, Class 39: Inheritance Summary: * Inheritance in general * Inheritance in Java * Examples: Course Prerequisites Notes: * Did anyone attend last night's talk? * What did you think about yesterday's class? * No, I haven't graded homework 3. See my plan for the reasons. * "What" can serve as a pronoun. * Expect exam 3 on Friday. * No, I didn't grade HW3. Big surprise. Read my plan for details. * Cool talk noon on Friday. More extra credit for attending. * CS courses you might take next semester and next year. Possible Fall CS Courses * CSC223, Software Design, Fall. [1/2 Required] Every fall * CSC261, Artificial Intelligence, Fall. [Optional] Every-other fall (computational linguistics the other fall) * CSC211, Architecture [1/2 Required] Every-other fall (operating systems the other fall) * 2-credit "Web programming" independent (details to follow next week). Perl, some C, SQL, lots of program management Probably every semester Details to follow * More Math. * ... * Special topic on Cryptology * CSC301, Algorithms (MAT218 prereq) (every fall) Possible Spring CS Courses * CSC201, "CS Under the Hood" (C programming and more) Every spring * CSC362, Compilers [1/2 required; alterantive with 223] Every-other spring (alternates with Networks; elective) Requires architecture * CSC341, Theory of Computation Every spring MAT 218 prereq * CSC302, Programming Languages Every spring CSC301 prereq * TEC154, Evolution of Technology + Sam teaches it. Yes, he can be as annoying about grading writing as he is about grading programming. + 8 a.m. + Required for technology studies concentration ---------------------------------------- Back to inheritance Important goals in software engineering * Document well * Code well ... which means + Code efficiently + Code elegantly + Code correctly + Code generally Important desire for language design: Help programmers write reusable code Two techniques in object-oriented design that support reuse of code * Inheritance * Polymorphism What are these things? * Inheritance: DaB: Objects can mutate (gain capibilities from other objects and then change them). Sam: The ability to define new classes (subclasses) based on other classes (superclasses) and automatically reuse the code from the superclasses in the subclasses. Example: Remember the book example we discussed a few weeks ago? If we've defined a book, and we need to talk about library books (e.g., for writing a library reservation system), we can just add a little bit of information to an existing book class. Everything we write is an object. We might define a generic two-player game and then specialize it for Raquetball, Squash, Ping-Pong * Consider the following questions for Friday + How does higher-orderness relate to polymorphism and and inheritance? + Why have multiple inheritance? Inheritance in Java public class SubClass extends SuperClass { ... }