Jump to page content Jump to navigation

College Board

AP Central

APAC 2009 Call For Proposals
AP Course Audit Web Site


Siemens Awards for Advanced Placement
Print Page
Home > AP Courses and Exams > Course Home Pages > Objects First

Objects First

Read more Strategies...

Contributed by Alyce Brady
Kalamazoo College
Kalamazoo, Michigan


On the first day of class I focus on objects. I describe an object-oriented program as a collection of "objects" that work together to perform a task. I then define an object-oriented "object" as being a combination of "state" and "operations" and provide some ways of thinking about what constitute state and operations.

Object = State + Operations


As I go through these, I tend to use a box (cardboard? wooden? open? closed?) and an elevator as my examples. Then I draw an object diagram for a box, showing some specific state information (cardboard, brown, 12" x 14" x 8", open, etc.) and a set of reasonable operations (open, close, add item, remove item, etc.).

Next I give students some blank object diagrams (I now have these on my Web site, below), and ask them to think of some objects in the real world and create diagrams showing their state and operations. We always get some obvious choices, and some non-obvious choices, too. The first time I did this, the three examples that students put on the board happened to be a cat, a car, and a carrot. This lead to an interesting discussion of how some operations were ones that other objects do to an object (e.g., the eat operation on a carrot), whereas others were ones that the object does for itself (e.g., the eat, sleep, and chase tail operations on a cat).





State Operations
Information about the object Tasks involving this object
Parts it is composed of What you can do to this object (e.g., open it, close it, move it)
Attributes that make this object different from others like it (e.g., color, material, size) What you can ask this object to do: Tell me your color. Tell me your size. Move yourself. Open up. Add this item to your list of contents.
State of this object between operations (e.g., open/closed, running/still) Special operations to construct objects (constructors)
List of other objects with which this object interacts and communicates (e.g., list of contents)  
  ABOUT MY AP CENTRAL
    Course and Email Newsletter Preferences
  AP COURSES AND EXAMS
    Course Home Pages
    Course Descriptions
    The Course Audit
    Sample Syllabi
    Teachers' Resources
    Exam Calendar and Fees
    Exam Questions
    AP Credit Policy Information
  PRE-AP
    Teachers' Corner
    Publications
  AP COMMUNITY
    About Electronic Discussion Groups
    Become an AP Exam Reader

Back to top