Learn Java Programming ideas Introduction to the first chapter object

Source: Internet
Author: User

First, the object-oriented five basic features:

1. All things are objects. treats an object as a peculiar variable, he can store the data, and can require it to perform operations on itself.

2. A program is a collection of objects that they tell each other to do by sending a message.

3. Each object has its own storage that is composed of other objects. in other words, you can create a new type of object by creating a package that contains an existing object.

4. No object has its type. The most important feature of each class is "what message can be sent to it".

5. All objects of a particular type can accept the same message.

Second, when trying to develop or understand a program design, one of the best ways is to think of the object as a "service provider." The program itself will provide services to the user, and he will do so by invoking the services provided by other objects. Your goal is to create (or preferably find in an existing code base) a range of objects that provide the ideal service to solve the problem. One way to get started is to ask yourself, "What kind of object can solve my problem if I can pull it away from the surface?" ”。

Thirdly, when establishing new classes, the combination (HAS-A) should be considered first.

To decide whether to inherit is to determine whether is-a can be used to describe the relationship between classes and to make it practical.

Learn Java Programming ideas Introduction to the first chapter object

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.