meeting -*- outline -*- * Motivations for OO Q: Why do people like OO? ** History (skip) *** Researchers in the 60's wanted to put their code and data together. *** Simula 67 Needed to organize complex simulation code (for a nueclar power plant) With simulations, you're constantly changing the program to accomodate new data, ideas, or to try to find out other things This is a central theme in OOP: the need to accomdate changes, to allow for programs to evolve and change easily *** Rediscovery by Alan Kay's group at Xerox PARC Trying to help kids learn led to Smalltalk-80 *** How AI research spinoffs helped OOP In AI, people do a lot of exploratory programming, i.e., they write a program and see what happens also needed to make changes easily and quickly *** change is important Q: Is change important in software in general? why? Yes, esp. in areas like user interfaces, simualation, graphics, AI, etc. Q: What kinds of changes are most common? changes to algorithms and esp to data structures ** Why OO is exciting? Q: How were you taught to go about programming? Q: How do you actually do it? *** Older approaches to programming don't deal with change well example, stepwise refinement (Wirth) ------------------------------------------ PRACTICAL LIMITATIONS OF TOP-DOWN DESIGN (STEPWISE REFINEMENT) Designed to fix decisions: requirements -> specs -> code -> test -> deliver change in requirements ==> redesign ------------------------------------------ spec = contract (signed) after contract is signed customer can't ask for more changes. *** why is change hard to deal with? Q: Why is change hard to deal with in programming? because of all the connections between the parts (coupling) because of the complexity of programs, hard to hold it in your head at once, we can't start over when we make changes *** OO deals with complexity through abstraction Q: How can you design software to avoid unnecessary coupling? We organize software into abstraction layers, so that we can understand the whole system at an abstract level. We use procedural abstraction to hide algorithms, so changes in behavior are localized. We use information hiding (ADTs) to hide representations, so changes in data/information are localized. Such changes are *very* common. *** OO deals with extension of behavior and data through inheritance Q: What OO features help you make small changes, like keeping extra information? So we don't have to start over when we add new behavior (methods) or new data/information (fields). By inheritance, one can define a new class (ADT) by stating its differences from old classes. *** summary By abstraction, OO has the power to produce large complex software systems, by inheritance, OO has the ability to evolve and maintain such systems OOP is *not* about making programs run faster It's about how to organize code to support evolution and change ** The downside of OOP *** Slows down programs due to: - additional memory requirements to support - possibility of memory leaks or g.c. - method calls do lookup (indirection) in general to find code (but a research topic to avoid these costs) *** Learning curve lots of abstractions mean lots of things to learn