What is the importance of object-oriented programming?

Source: Internet
Author: User
For OO I am a rookie, and now just a general understanding of C sharp and Python syntax. As for C + +, Java did not learn, I am not a CS related professional.

RT, at first saw a lot of people said OO advantage is to improve the maintenance of the program. Later, it was said that OO abstract encapsulation layer will cause difficult to modify and maintain.

Baidu Encyclopedia is saying "... Better understanding of the way to the complex system of analysis, design and programming, to improve the efficiency of programming "

I now feel that oo in addition to the graphical interface must be used, it seems that there is no need to use other places.

What is the importance of OO?

Reply content:

Nothing but Oo can do, oo more is to give you a kind of ability, a Ignore detailsAbility: The more you neglect, the more complex the problem can be accommodated by human limited intelligence, and thus improve productivity.

The essence of any abstraction is neglect, and OO is just one of them. Oo is just a way to solve a problem
Encapsulation, inheritance, polymorphism ... is an object-oriented basic feature
But no key can open all the locks in the world ... Barney Stroustrup said that C + + can have the present development, the victory is not the language itself, but a thought. In programming, Ood this kind of thought guides you in addition to thinking about the process of completing a task, what resources it takes, and also pushing you to think about the objects needed to complete the task (well, I'm not talking nonsense.) In other words Ood Better Mapping (abstraction) of reality and programming, and programming in solving real problems is itself the final mapping of real problems (abstraction) into mathematical logic to calculate。 Of course, some ood related features, such as inheritance, encapsulation, polymorphism, interface, etc. in addition to improving the abstract ability of the program, but also improve the maintenance of the class.

Finally, send a purely funny (ZZ):
Scheme Dafa is good

The process of the day out of the C-security peace
People are doing the day looking at assignment statements leaving a plague
The hands of the world to destroy the hand to rewrite the peace
Sincerity read SICP good scheme Dafa ping bao
All beings are functions to the present sinister forgetting frontier
Scheme disciple says the truth teaches you to program not to refuse

Getting rid of the process early and gaining new life

Internet search "Nine comments Dennis Ritchie" have the truth

2016-5-10 16:03: Supplement
Personally, compared to the process-oriented thinking and programming, the advantages are direct, programming straight to the theme and results, early development, low cost of design. This approach is naturally used for small-scale functions and implementations, for one-time development and use of programs, and for the early development of many uncertain programs. In the beginning of the C language, especially the use and strengthening of this mode of thinking.

The disadvantage is that there is usually no hierarchy, it is easy to make the "reusable" part and the specific "logic" coupled together, so that the reuse of the part is often difficult to reuse. As a result, process-oriented code is easily submerged in a lot of code without layering. For project maintenance and reconfigurable, it is unfavorable.

and object-oriented programming, in terms of encapsulation, the algorithm, the data to do some classification. Externally exposed to a design interface. This allows the business logic to be divided into a clearer and more hierarchical sense, allowing programmers to work on a specific subdivision of a whole at a time. Therefore, it is beneficial for many people to cooperate.

If only encapsulation, inheritance is used, then it is only object-based. The most important feature of object-oriented, is to use its polymorphism (that is, when using OO, you only use virtual functions, and through the ancestors of the interface to manipulate them, you can feel and play out the power and advantages of OO language, as well as the beauty of OO), the final level of the project is more clear and reasonable definition. Without compromising the overall design framework, you can define, adjust, and customize the personalization behavior of a specific object at any time by polymorphism.

Of course, it's not easy to do that, and the end result is usually not the first thing you can foresee. Often need to follow the development, constantly adjust the definition of each interface, can gradually reach the final reasonable state. Therefore, the initial development cost in the development process is slightly higher. By the time these definitions mature, the ease of use, and maintainability above, are more advantageous than the process-oriented code.

In addition, the compiler's support for OO programming languages is an important help for programmers. For example, the compiler assumes responsibility for the destruction of temporary objects (programmers only need to focus on writing destructors). This allows us to alleviate some of the burden of memory management and resource maintenance when using objects. For example, in a function of the C language, if you request and open multiple resources, you need to carefully track them and take care of their recycling and closing (especially if the function is in the middle of the return case). In C + + it is easy to define a temporary object at any time (because the compiler will refactor them at the appropriate time).

In the following original answer, I mainly put forward to some of the ideas I have seen, some people's understanding of oo too rigid, and the non-OO as a scourge, these views are too absolute. Just like some people apply design patterns, too blunt too formal is not good.

You have two options: oo, non-oo.

----
The most important function of object-oriented is to make some classification and division at the language level. This gives additional information that helps to improve the maintainability of the program, and is controllable.

That is, it conveys the density and logical relationship between data, between functions, between data and functions. This is similar to the division method by the piecemeal of complex tasks and the simplification of tasks.

At the same time, the concept of object is established in the programming model, it is usually more suitable for human thinking habit, through the reasonable encapsulation, design good object interface, thus helping people to develop and control their own code more easily.

On the landlord question, I added, OO choice and GUI is completely independent. The GUI can also be developed in a process-oriented manner. It is also useful to use OO to program in various situations (not necessarily GUI) that are suitable for OO.

Then object-oriented use, people easily rigid, to beware:

(1) Excessive oo. Unnecessary deepening of the object-relational network depth reduces the maintainability and controllability of the program and ultimately loses control of the project.

(2) Some people are completely opposite to the process, which is a kind of dogmatism and stiff and rigid understanding. In fact, absolute OO, is not the most correct. No matter the brute force OO can only be self-defeating stupid person. Not aware of, OO is not applicable to all models, or, on many occasions, there is no need for OO and no special benefits of OO.

In fact, it is a reasonable combination of OO and process-oriented to solve the problem. Rather than an either/or relationship.

I used to see in the technical forum that some people said, this is not oo ah, if they see the results of OO language compilation, I am afraid to commit suicide .... The Foundation is the encapsulation: information hiding, simplifying the formal parameter design; OOP makes the implementation of reactive programming (Actor model, message communication, event mechanism, asynchronous) become natural. Compared to the first generation of paper tape program and the future of the modular programming model of natural language, object-oriented is only a small step, it in thinking to help more and more people learn programming and like programming, it is obvious that as long as the programming has not formally entered the primary school textbooks we are not satisfied. Reduce global variables ... Of course it's the object. For beginners, the most obvious benefits of OO may not be felt when you write code.
But when you use someone else's library, you find it. OO Big Three: encapsulation, inheritance, polymorphism.

Encapsulation is to ' remove global variables '.
Inheritance is to ' remove the code DUP '.
Polymorphism is to allow ' inheritance ' to be established (Jianghan).

Thus, oo importance is two points, "1. Go to global variables, 2. Go to code DUP".

So why are these two points so important?
People who have written and tracked and maintained large-scale applications naturally understand that
or to receive and maintain the ' global variables, code DUP fly the project ' people can understand.
  • Related Article

    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.