Held: Monday, 8 March 2004
Today we begin our exploration of the object-oriented programming
- Contrary to your claim, my book is not in the bookstore. The book in the bookstore, Bruce Eckles's Thinking in Java, is an optional reference text. It is worth the money.
- An introduction to object-oriented programming.
- What sets Scheme apart from other languages you've used?
- The rest of this part of the outline intentionally left blank.
- As you might guess, object-oriented languages concern themselves with
- You might have a sense of what a
real world object is.
- In computerese, an object is a collection of information
(sometimes called attributes or fields) and
operations that the object can perform (called methods).
- For example, we might say that the textbook I used last year
- has title
Java Structures (attribute)
- is published in hardback (attribute)
- was written by Dwayne Bailey (attribute)
- contains text that you can extract (the text is an attribute, the extracting
of the text might be considered a method)
- We often categorize objects into classes. A class specifies
common aspects of a set of objects. These aspects are often
generic attributes and specifications of methods (E.g., ``all objects in
this class have a color, a size, and can draw themselves''.)
- Almost every book has a title
- Almost every book has one or more authors
- Almost every book has text that you can extract
- Most object-oriented languages support inheritance, in which
classes can be based upon other classes. For example, we might say that
library books are a subclass of books and inherit all the
attributes of books. Library books also extend books.
- Since books have titles, library books also have titles
- Since books have authors, library books also have authors
- Library books also have
loan records: information on who has
- Some notes on subclasses:
- A subclass inherits the attributes and methods of its
- The parent class is often called a superclass.
- Most object-oriented languages support polymorphism, in which
a member of a subclass can be used in place of a member of a superclass.
- If we know how to read a book, we know how to read a library book.
- Many object-oriented languages are event-driven. That is,
you can specify
when this event happens, call this method
of this object.
- A key aspect of object-orientation (and good program design in any
language) is information hiding. In general, objects
should know what other objects do, but not how they
- For example, you might know that a
Menu object can
draw menus on the screen, but it's not important to you how it
- This property is also called encapsulation.
- Polymorphism, inheritance, and encapsulation are three key aspects
of object-oriented programming.