Monday, January 14, 2008
What is An Object?
An object can be considered a "thing" that can perform a set of activities. The set of activities that the object performs defines the object's behavior. For example, a "StudentStatus" object can tell you its grade point average, year in school, or can add a list of courses taken. A "Student" object can tell you its name or its address.
The object's interface consists of a set of commands, each command performing a specific action. An object asks another object to perform an action by sending it a message. The requesting (sending) object is referred to as sender and the receiving object is referred to as receiver.
Control is given to the receiving object until it completes the command; control then returns to the sending object.
For example, a School object asks the Student object for its name by sending it a message asking for its name. The receiving Student object returns the name back to the sending object.
A message can also contain information the sending objects needs to pass to the reveiving object, called the argument in the message. A receiving object always returns a value back to the sending object. This returned value may or may not be useful to the sending object.
For example, the School object now wants to change the student's name. It does this by sending the Student object a message to set its name to a new name. The new address is passed as an argument in the message. In this case, the School object does not care about the return value from the message.
Labels: What is An Object?
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment