Java programmer must READ: Basic (3)

Source: Internet
Author: User
Tags object
Program | Programmer java programmer must read: Basic time: 2001/09/13 13:31 Author: ZSC Pacific Network College

 
2.2 What is the message

The interaction between software objects and communication is the use of messages.

A single object is usually not very useful. Instead, an object is usually a larger program or application that contains many other objects. By interacting with these objects, programmers can gain higher-order functionality and more complex behavior. If your bike does not use it, it is a pile of aluminum alloy and rubber, it does not have any activity. It is only useful when there are other objects that interact with it.

The interaction and communication of software objects with other objects is achieved by sending them to other objects. When object A wants object B to execute the method in a B, object a will message to object B. As shown in Figure 3.

(Figure 3)

Sometimes, the receiving object needs more information as it can correctly know what to do. For example, when you want to change the gears of a bicycle, you have to point out which gears. This information is passed as a parameter to the information. As the reality shown in Figure 4, a message consists of three components:


Object addressed to Message (Yourbicycle)


Name of the method to execute (changegears)


All parameters required by this method (Lowergear)

(Figure 4)


The above three components are given sufficient information to perform the appropriate method for the recipient's object. No further information or context is needed.

The message provides two important benefits:


The behavior of an object is expressed through its methods, so message passing supports all possible interactions between objects.


objects do not need to send and receive messages to other objects on the same process or on the same machine

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.