亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

java - 什么是object oriented?
巴扎黑
巴扎黑 2017-04-17 11:13:09
0
4
656

我目前在英國讀大一計算機(jī),是個超級菜鳥,我不太明白什么是object oriented。。。中文翻譯過來似乎是面向?qū)ο螅ㄓ锌赡芊g錯了)。 我搜索過有關(guān)于他的解釋,但是還是不是很明白,都解釋的太專業(yè)了,請問又問能夠很簡單明了并且完整的給我解釋一下什么是object oriented么? 謝謝大家了

巴扎黑
巴扎黑

reply all(4)
左手右手慢動作

What is object-oriented?

When we look at problems in the real world, we will find that every thing has its own attributes, indicating what it is, and the behavior of this thing, which is used to interact with other things.
Object-oriented is such an idea. When modeling, the problem is abstracted into many objects. Problems are solved through interactions between objects.

Why object-oriented?

The advantages of object-oriented are mainly in two aspects:

  1. Our daily thinking mode is also object-oriented. We often say that so-and-so can do something, and if we give him the corresponding needs, he is an object. During demand analysis, it is easier to model.

  2. After the program is implemented, it has better maintainability, reusability and scalability.
    Because the objects are independent, TA can be used in project A, and TA can also be used in project B. We can also extend and change the object through inheritance.
    Because the object is encapsulated, changes in the object's internal implementation will not affect interaction with the outside unless the interface changes.

How to learn object-oriented?

  • Master the basic concepts of encapsulation, inheritance, and polymorphism, and think and understand them from daily life
  • Learn design patterns
洪濤

Object oriented, simply put, is a programming routine.

What are programming routines

Programming is to use existing information to generate new information.

Specifically, we first convert existing information into data (Data), and then operate on these data to obtain new data, and the new data contains new information. The method of manipulating these data is called a function.

From this perspective, a program is a bunch of data and functions, and programming is about designing and organizing data and functions.

Different ways of design and organization are called programming routines, or paradigms. Among them, object-oriented is one of the paradigms.

Basic principles of object-oriented

The core of object-oriented is to encapsulate certain data and functions used to operate these data.

The function encapsulated into the object is called the method of the object.

Because data and functions are encapsulated into objects, when we need to operate certain data, we pass a message to the corresponding object and ask the object to return the answer we need. After the object receives the message, it calls the method encapsulated within itself, calculates the answer, and then sends us back a message containing the answer.

The above is the basic principle of "object-oriented".

Benefits of object-oriented

The advantage of "object-oriented" is that data and corresponding functions are encapsulated together to achieve the separation of interface and implementation. In this case, changes to the lower layer will not affect the upper layer. As we have said before, the methods inside the object are essentially functions. The definition of this function is called the implementation of the method. As long as the interface provided by this method does not change, changes to the implementation of the method inside the object (that is, the function definition) will not affect other parts of the program.

Of course, object orientation also has its disadvantages. The most prominent thing is that if you blindly emphasize that "everything is an object" and force all programming to follow object-oriented routines, and do not allow other routines at all, it will lead to some cumbersome designs.

Other concepts of object-oriented

Once you understand the basic principles, it will be easier to understand other concepts.

If some objects are similar, then correspondingly, the functions (methods) that operate on them should also be similar. How to share methods at this time to avoid duplication?

One idea is to introduce the concept of class, which is to treat similar objects as one class. Then classes are also objects and have bound functions or methods. The methods of these classes can be shared by objects belonging to that class. In the same way, similar categories can also be classified into larger categories. This forms the concept of parent class and subclass. Subclasses can inherit the methods of the parent class, and similarly, they can inherit the methods of the grandpa class (the parent class of the parent class).

The above is single-line inheritance, which means that a class can only inherit methods from its ancestors. This is sometimes inconvenient. One idea is to allow a class to have multiple parent classes, which is multiple inheritance. Another idea is to allow classes to borrow methods from other classes, which are mixins.

The opposite idea to classes is to introduce the concept of prototype. If objects A and B are similar and are handled by classes, that is to construct a class C, and then treat A and B as two instances of class C. If we use prototypes to deal with it, we use A as the prototype to construct a B.

Based on these two ideas, more concepts and corresponding programming conventions have been formed, which will not be introduced here.

As for the specific programming language, whether it provides a mechanism to implement object-oriented programming, whether it natively supports object-oriented programming, and in what way, whether it only supports object-oriented programming, that is another question.

黃舟

Continue to introduce ideas...

means object-oriented. It is different from programming models such as process-oriented. You can refer to Baidu Encyclopedia

You can refer to Head First Java/Head First C#

伊謝爾倫

Object-oriented, I believe you have seen the complex and accurate term, so I won’t post a link to Wikipedia. It is a programming paradigm.

To put it simply, you first think about what objects are in the system and what data and behaviors they have. For example, if you build a Q&A website, then "question" is a category. "Question" will have "title", "description" and other data, "answer", "delete", "close", "like", "dislike", Actions such as "modification" can occur around its instances. The programming activities carried out around this basic idea are called "Object-oriented Programming".

Of course, there is much more to object-oriented than that. For example, inheritance, overloading, polymorphism, etc.

PS: In Taiwan, it is called "Object-oriented".

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template