CSC153 2004S, Class 37: Designing Objects Admin: * Sam is hoarse (If you didn't understand that, I won't talk and I'll just write) * Survey results * Class is going too fast: 1 1 2 2.5 2 4 * less talk/more lab: 2 2.5 4 2 5 4 5 * less lab/more talk: 4 2.5 2 3 1 1 1 * Questions on the homework? * Do we have to use the six Ps? No, but it would be nice. * Can we pass functions? With a clever hack (to be discussed) * Read EIJ, Chapter O2 (Inheritance) * Cool convo tomorrow Overview: * Field trip to science elbow! (Free coffee and stuff!) * Passing functions * Object-oriented design basics, revisited * Protection * Reuse * Exercise Fun with functions as parameters: * You can simulate higher-order functions with objects * Some functions are easier to build more quickly * Can still generalize About object-oriented design: * Program in terms of objects * Three related concepts: Encapsulation - Protect and separate interface from implementation Inheritance - Extend: Add fields methods Modify: Override methods Example: The function thing above Question: Why are anonymous functions useful? Because they save programmer effort. Polymorphism Polymorphism vs. overloading * Polymorphism: Write function once, can apply it to similar objects * Overloading: Write function with the same name multiple times with different parameter types Common problem in object-oriented design: How do I choose which objects to make and how do I decide fields and methods of those objects? * Idea from reading: Tell stories