There is a fundamental difference between a message

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: imitive element of a program written in an OOP language. Each object consists of a set < procedures (known as methods) and some data. It stores the data in variables and responds to messages received from other objects by executing the procedures (methods). A method is a collection of operations that specifics the reaction of the object when it receives a message that corresponds to that method. A program written in a pure OOP language is a collection of objects that communicate with each other. Virtually everything, from items as simple as the integer constant 8 to a complex file-handling system, are objects. As objects, they are treated uniformly. They all have local memory, inherent processing ability, the capability to communicate with other objects, and the ability to inherit characteristics from ancestors. Each object can be viewed as an abstract data type because it is an autonomous entity with its private data and methods. Note that an object contains both functions (procedures/methods) and data that describe the characteristics of the object. In other words, an object encapsulates both data and functions. Method A method of an object defines the set of operations that the object will execute when a message corresponding to the method is received by the object. In a sense, methods are like function definitions, complete with parameters and the capability of returning values. The binding of a message to a method is dynamic. The entire collection of methods of an object is called the message protocol, or message interface, of the object. Figure 12.13 illustrates the object model used in OOP. Message The mechanism to support communication between objects is through messages. That is, all computing in a program written in an OOP language is done by sending a message to an object to invoke one of its methods. A reply to a message is an object, which returns the requested information, or simply notifies the sender that the requested processing has been completed. There is a fundamental difference between a message sent to...
View Full Document

This document was uploaded on 04/07/2014.

Ask a homework question - tutors are online