Java Basics--talking about object-oriented

Source: Internet
Author: User

At this time last year, the impulse to write a "brief introduction of object-oriented technology", first of all it seems to think: what is written and what? (PS: Although the blog is still not very well written now) but, in the Java study once again had to object-oriented, so, on a "talk about object-oriented" as a new Year's appetizer.

Object-oriented is a kind of thought relative to process-oriented.

Different from the process-oriented:

Process-oriented is a function-based, the completion of a variety of operations, emphasizing the process, and object-oriented is based on the object, emphasizing the object.

For example, the elephant in the refrigerator is divided into several steps, song Dandan said: three-step Bai,

The first step: Open the refrigerator door,

Step two: Put the elephant in,

Step three: Close the refrigerator door.

where "open" "Storage" "closed" are functional behavior, in the code of the visual embodiment is a function or method, which is a process-oriented with functional behavior as the main body of thought embodiment.

Using object-oriented thinking to analyze the steps are as follows:

The first step: the refrigerator opens,

Step two: Refrigerator storage,

Step three: The refrigerator is off.

We can see that all the operations are "refrigerators" as the main body, the function is encapsulated into the refrigerator (object). In other words, the refrigerator itself has the "open", "storage", "close" behavior function, we only need to let the refrigerator perform its functions can be.

An example of an object in life: A mobile phone is an object, and a mobile phone has many features, such as height, width, thickness, color, weight, etc., which are called properties of the object. At the same time, mobile phones also have many functions, such as mobile phones can listen to music, phone calls, hair information, see movies and other functions, these functions are called the method of the object.

Characteristics:

1. is a more in line with people's thinking habits of thought (based on this, not to understand)

2. Complex things can be simplified

3. Convert programmers from performers to conductors.

Development process:

Constantly create objects, use objects, and command objects to do things.

Design Process :

is to manage and maintain the relationships between objects. The use of design patterns or other connections between objects, so that the object can be closely related to more efficient usage of objects.

How to make a program object-oriented:

1. Analyze which objects are included in the system?

2. What can each object do?

3. Define the relationship between each object.

Characteristics:

Package (encapsulation)

Inheritance (inheritance)

Polymorphic (polymorphism)

When learning object-oriented, if you can understand the comparative basis of knowledge, you can be very familiar with the object-oriented. Made a map as follows.


Summary

Face object as a programming idea has been constantly developed and recognized, which contains a lot of things, I also do not know, the above mentioned points will be in the future of learning to continue to supplement and deepen the expansion to meet their thirst for knowledge of the heart, the harvest is often rich, perhaps in the future, With the deepening of understanding, I will also write a "three talk about object-oriented" (⊙o⊙) ... Suddenly think of Forrest Gump said a sentence, on the first day of the new Year with everyone to encourage: life is like a box of chocolates, you never konw what you ' re goingto get.

Java Basics--talking about object-oriented

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.