Object-oriented programming and process-oriented differences

Source: Internet
Author: User

Object-oriented and process-oriented differences, it is difficult to use one or two words to understand.Process oriented is a direct programming method, which is based on the thinking of programming language. In particular, the C language is the process of language, it is to execute a set of statements in order to implement a function, the execution of these statements is the entire program. The process of solving the same problem in different languages is not the same.Object-oriented is an abstraction of a higher degree of programming. It focuses on solving the problem itself rather than the language. Its goal is to make the module more abstract and reusable. The object-oriented purpose is to be reusable.For example, we're going to write a calculator program. This computer currently only requires subtraction four kinds of operations.With a process-oriented approach, we may write a main function directly. Then we begin to define some data structures and then start writing Add,sub,multi,div functions to implement the functions.With an object-oriented approach, we will first define a calculator class. Then define some of the necessary data members and then define the four member functions of the ADD,SUB,MULTI,DIV (the functions of these four functions are implemented in the same way as the four above should be basically the same).From the above implementations, the difference between the two implementations is not very large, and even the second looks somewhat superfluous.Next, we'll expand the calculator so that it can calculate the exponent.With a process-oriented approach, we'll copy all of the code implemented above and then add a power function. With an object-oriented approach, we define a Calculatorex class that inherits from Calculator, and then implements the power function in Calculatorex.The above is just a simple extension, the difference between the two is obvious. Process-oriented is a pure code-level reuse. Object-oriented reuse is more elegant, it can be code-level, or class-level, it can be interface-level, or component-level, or even service-level. Put aside these reuse concepts. We assume that the first implementation is not a simple four function, but a complex library, the second increase is not a function but an extension library. This time the object-oriented advantages will be more obvious manifestation. Process-oriented is a loose part, and object-oriented is a system.These are my own understandings, which may not be entirely true. There is an official definition of object-oriented, but different people have different understandings. So there are many things in the learning process to understand the experience. But if you don't do something about it, it's hard to understand these concepts in place.And, C,c++,java, these are all languages, and there is no object-oriented distinction between them. Using C can also write object-oriented programs, see the Linux kernel code to know. C++,java can write process-oriented programs, they call object-oriented programming languages because they provide language features that are easier to implement object-oriented programming methods, not that they can only do object-oriented programming.It is not that object-oriented must be better than process-oriented. In many areas, object-oriented methods cannot be implemented, such as hardware programming and embedded programming, where real-time and high-efficiency requirements are not available for object-oriented applications. The main object-oriented domain is also used in large-scale, complex software systems.

Object-oriented programming and process-oriented differences

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.