11-object-oriented basics, 11-object-oriented

Source: Internet
Author: User

11-object-oriented basics, 11-object-oriented
Object-oriented Basics

First, let's give an example where I asked James to help me buy cigarettes:

Method 1:

1. I said to James, "Go down to the street and buy me a pack of cigarettes ."

2. You must first stand up and then turn right to the backdoor

3. If the door does not close, you can go out directly. If the door is closed, you need to open it and then go out again.

4. Turn right after going out and enter the stairs

5. If there are many people going up or down the stairs, you need to go right.

6. Then, on the road, if you see an old lady in need to help her

7. Then buy cigarettes

8. Check whether the change is true. If it is, return it.

......

Method 2:

1. I told James to buy me a pack of cigarettes.

2. James bought the cigarette and handed it to me.

We can see that in the two methods that let James buy cigarettes, the first method should be taken into account in the process of buying cigarettes, and the second method is to find a person to do things.

Therefore, the first method is process-oriented, and the second method is object-oriented.

 

The so-called process-oriented approach is to write code from top to bottom based on the business logic.

Object-oriented means to bind data and functions for encapsulation, so that programs can be developed more quickly and repeated code rewriting can be reduced.

Class and Object

The class is equivalent to the drawing when the plane is licensed, and the aircraft created with it is equivalent to the object

Class

Group by group

A set of entities with similar internal states and motion patterns (or collectively called abstract)

 

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.