Functions, including first-class, review demo - Plotting functions with the turtle! - Functions with composition of multiple sines - "harsh" audio distortion with transistors Class: A definition of a collection of objects and data Object: An instance of a class Instance: An example of a definition of something - Car example - In the car example, classes might be expensive Method: A function that is part of a class Property: A variable that is part of a class These are a way of organizing data and functions together Maintains state without global variables There are objects in the standard library - Files - Strings - Lists A couple more terms: - Constructor - Destructor Compare and contrast with Java classes: Java expects you to love objects Java: Everything is organized in classes - Want a simple program? Use a class - Want a library? Use a class - Want a function? Put it in a class, and call it a method - Want a bunch of constants? Put them in a class as static properties - Want a global variable? Use a class-level static variable instead - Some of these can be hacked around, but we're going with the flow here Python: Classes underly everything - They're like the floor. You can interact with it, or just walk on it. - Python itself is built object-oriented Let's think about what is presented to the user! - How many of you have semi-metallic brake pads on your car? - vs. organic or ceramic Was Java written by heartless object proponents? - Do they attach eating to the cat or the food? Java is designed for graphical application programming! - GUI is usually a collection of objects! - If you're going to program with OO, might as well embrace it! - ffui - Don't play salmon We can make classes that represent things - Like a square - methods: area, perimeter, draw Ok, how about a collection? With super bonus iterators!