CS 541 Lecture -*- Outline -*- * Object-oriented design: coping with change advert: what is object-oriented design? don't see functions everywhere, see abstract data types... helps cope with change ** Motivation *** The problem: coping with change in software *** partial solution: information hiding and data abstraction as in CLU builds on ideas already in Simula I and Simula 67 (class concept). *** other problems: reuse of designs regularity, user extensions to system users want to extend design themselves (new functions, new data types) Simula 67 addressed some of these problems too These problems are addressed by object-oriented design try to reuse existing abstractions define types by extension of existing ones (inheritance) use dynamic binding (table-driven design) allow users to add types later ** terminology showed the video about OOP from Borland here asked them to watch for definitions of 1. object 2. message passing, polymorphism 3. class 4. inheritance, subclass 5. method talked about these and how they relate to CLU afterwards. *** Objects = data + operations idea: object contains its operations = record with data + procedures in it! send it a message to ask it to do something (e.g., howMuch) message send = operation fetch + call Smalltalk (as in Simula 67) view: operations are part of each object ______________________ | | | | | _________ push: | | | | | |_______| | | | 3 | pop | |_______| | | | 2 | | | |_______| top | | 1 | | | |_______| | | | |______________________| state = instance variables (= CLU rep) operations = code that responds to messages (methods) having operations as part of objects allows one to send a message without having to know the object's type (polymorphism) e.g., can ask any animal to eat, don't have to know how it eats, it knows (method inside)