What is the importance of object-oriented programming?

Source: Internet
Author: User
For OO, I am a cainiao. Currently, I only have a general understanding of Csharp and Python syntax. I have never studied C ++ or java. I am not a cs-related major. RT. At first, many people said that the advantage of OO is to improve the maintainability of the program. Later, it was said that too many layers of OO abstract encapsulation would make it difficult to modify and maintain them. Baidu encyclopedia says 【...... it is easier for people to understand how to analyze, design, and program complex systems to improve programming efficiency.] I feel that OO must be used in addition to graphic interfaces, it seems that there is no need to use anything else. For OO, I am a cainiao. Currently, I only have a general understanding of C sharp and Python syntax. I have never studied C ++ or java. I am not a cs-related major.

RT. At first, many people said that the advantage of OO is to improve the maintainability of the program. Later, it was said that too many layers of OO abstract encapsulation would make it difficult to modify and maintain them.

Baidu encyclopedia says [more conducive to human understanding for complex system analysis, design and programming, to improve programming efficiency]

I now feel that in addition to the graphic interface, OO does not seem to have to be used in other places.

What is the significance of OO? Reply content: nothing can be done only by OO. OO gives you more capabilities and Ignore detailsCapabilities: the more you ignore, the more complicated the human intelligence can accommodate, and thus improve production efficiency.

The essence of any abstraction is ignored, and OO is just one of them. OO is just a solution to the problem.
Encapsulation, inheritance, polymorphism... is the basic feature of object-oriented
But there is no key to open all the locks in the world... Barney Stroustrup said that C ++ can develop as it is, and what wins is not the language itself, but an idea. In program design, the idea of OOD guides you not only to think about the processes and resources required to complete a task, but also to think about the objects required to complete the task (amount, I am not talking nonsense .) In other words, OOD better ing (abstraction) the reality and the programming, while the programming itself is the final ing (abstraction) of the real problem into the mathematical logic for calculation.. Of course, some OOD-related features, such as inheritance, encapsulation, polymorphism, and interfaces, not only improve the abstract ability of the program, but also improve the maintainability of the course.

Finally, send a funny message (zz ):
Great Scheme Method

Day-out process-type C-safe
People are watching the assignment statement on a daily basis.
Pointers are useless. overwrite them to ensure security.
Sincerely read the good Scheme, Dafa, and security
All sentient beings are functions that are at the forefront of the evil world
Scheme disciple says the truth teaches you how to program MO No

Get rid of the process and get new users as soon as possible

Search for "Nine ratings Dennis Ritchie" on the Internet to find the truth

16: 03: Supplement
I personally think that, compared with process-oriented thinking and programming, it has the advantage of being direct. Programming goes straight to the topic and result. early development and design costs are low. For small-scale functions and implementations, one-time development and use of the program, and for a lot of uncertain programs in the early stages of development, it is natural to adopt this method. This thinking mode is especially used and enhanced when you are new to c.

The disadvantage is that there is usually no layer. It is easy to make the reusable part and the specific logic coupled together, making it difficult to reuse the reusable part. Therefore, process-oriented code is easily drowned in a large number of codes without a sense of parallelism. It is unfavorable for project maintenance and reconfiguration.

In terms of encapsulation, object-oriented programming classifies algorithms and data. Externally exposed interfaces that have been designed. This makes the business logic clearer and more appealing, so that programmers can focus on specific segments in a whole each time. Therefore, it is conducive to collaborative cooperation among multiple individuals.

If only encapsulation and inheritance are used, it is only based on objects. The most important feature of object orientation is to use its polymorphism (that is, when OO is used, you only need to use virtual functions and operate on them through the ancestor interfaces, you can feel and exert the power and advantages of the OO language, as well as the beauty of OO), and ultimately define the project level more clearly and reasonably. Without affecting the overall design framework, you can customize, adjust, and customize the personalized behavior of a specific object at any time through polymorphism.

Of course, it is not easy to achieve this, and the final result is usually not foreseeable at the very beginning. It is often necessary to adjust the definition of each interface as the development progresses to gradually reach the final reasonable state. Therefore, the development cost in the initial stage is slightly higher. After these definitions are mature, their ease of use and maintainability will all be more advantageous than process-oriented code.

In addition, the compiler plays an important role in assisting programmers in OO programming languages. For example, the compiler assumes the responsibility for creating temporary objects (the programmer only needs to focus on writing the destructor ). This reduces the burden of memory management and resource maintenance when using objects. For example, in a function in c, if you apply for and open multiple resources, you need to follow up carefully, they are responsible for recycling and disabling them (especially when the function returns in the middle ). In c ++, it is enough to easily define a temporary object at any time (because the compiler will parse them as appropriate ).

In the original answer below, I mainly raised my disapproval of some of my views. Some people have too rigid understanding of OO and regard Non-OO as a beast of the flood, these opinions are too absolute. Just like some people apply design patterns, it is not good to be too rigid or formal.

You have two options: OO and non-OO.

----
The most important feature of object-oriented programming is to classify and classify objects at the language level. This provides additional information that helps improve the maintainability and controllability of the program.

That is to say, the confidentiality and logical relationship between data, between functions, and between data and functions. By dividing complex tasks into zero, division of labor and collaboration and task simplification are achieved, which is similar to divide and conquer.

At the same time, the concept of object is established in the programming model, which is usually more suitable for human thinking habits. Through reasonable encapsulation, a good object interface is designed, this makes it easier for people to develop and control their own code.

With regard to the landlord's questions, I have added that the OO selection is completely independent of the GUI. GUI can also be developed in process-oriented mode. In a variety of scenarios suitable for OO (not necessarily GUI), it is also very beneficial to use OO for programming.

Then, with the use of object-oriented, people are easily rigid and should guard against:

(1) Excessive OO. It is unnecessary to deepen the network depth of the object relationship, which will reduce the maintainability and controllability of the program, and eventually lead to project failure.

(2) Some people are totally opposed to process orientation. This is a type of dogmatism and rigid understanding. In fact, the absolute OO is definitely not the most correct. No matter how hard OO is, it can only be a self-defeating stupid person. Not aware. OO is not applicable to all models, or in many cases, there is no need for OO or special benefits without OO.

The actual situation is generally the rational combination of OO and process-oriented to solve the problem. Rather than the relationship between the two.

In the past, I often saw people in technical forums saying that this is not oo. If they saw the compilation results of oo language, they would be afraid of suffering from suicide .... Encapsulation: Information Hiding simplifies the design of parameters. OOP makes the implementation of Reactive Programming (Actor Model, message communication, event mechanism, and Asynchronization) natural. Compared with the modular programming model of the first generation of tape program and the future natural language, object-oriented is only a small step. It helps more and more people learn programming and prefer programming in terms of thinking. Obviously, as long as programming has not officially entered the elementary school textbooks, we are not satisfied. Reduce global variables... Of course it's an object ~ For beginners, the most obvious benefit of oo may not be felt when you write code.
But when you use someone else's library, you find the three major parts... OO: encapsulation, inheritance, and polymorphism.

The encapsulation is to 'remove global variable '.
Inheritance aims to 'remove code dup '.
Polymorphism is used to enable inheritance (Great sweat ).

It can be seen that the importance of OO is also two points, "1. Go to the global variable, 2. Go to the Code dup ".

So why are these two points so important?
People who have handwritten data and tracked and maintained large-scale applications naturally understand that,
Or those who have received and maintained the 'Global variables, code dup flying project 'can also understand.

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.