Process-oriented and object-oriented differences

Source: Internet
Author: User

Object-oriented and process-oriented differentiation the term process orientedis an object- oriented oriented) appear after the appearance of the opposite.  In fact, it was basically called "structured programming" in the past. Early programming, the use of shared variables (global variables) and GOTO statements, and later proved that all meaningful program processes can be implemented using three basic processes (order, selection, repetition), and put forward "goto harmful say", from the way people are programmed to make a major change, Each language provides the implementation of these basic control structures and provides the ability to localize data access and some form of modular/separate compilation mechanism. On these basis, people's programming activities are basically implemented by writing function/process for different purposes, so it is called "process oriented".

The process-oriented development approach is an abstraction of the underlying structure of the computer, which clearly divides the contents of the program into two parts: data and manipulating data. The core problem of this programming approach is the development and optimization of data structures and algorithms. The mechanism provided by the C language is a typical structured programming application.

Object-oriented is the revolution of software development mode after the structural revolution. The main object-oriented idea is based on abstract data type, ADT: During structured programming, it is found that it is very convenient to bind a certain data structure and the various operations used to manipulate it in a modular way. When programming in this way, the interface of the data structure is fixed. If the abstract data type is further abstracted, it will be found that the instance of this data type as a specific thing, thing, object, can raise people to the programming process of how to view the problem of a major change. Abstract data type methods Although there are some abstract capabilities, but the core is still data structures and algorithms. The object-oriented approach directly treats everything as an independent object, and the process of dealing with the problem is not mainly about how to use data structure to describe the problem, but directly consider reproducing the relationship between the objects in the problem. It can be said that the most important value of the object-oriented revolution is to change the way people look at and deal with problems.

In an object-oriented approach, objects can accept messages from other objects, or they can send messages to other objects. There are language static types that determine the scope of an object's acceptable message, which is called an interface for the type of object. In some languages, objects can accept any message, but only respond to meaningful messages. Objects can contain other objects, which become "aggregates," and objects can be treated as objects of other types, which require that the type of the object "inherit" another type. An object can be accessed only through the interface it provides, and its internal implementation is inaccessible, which becomes "encapsulated." The three core elements of an object-oriented approach are encapsulation, inheritance, polymorphism.

Process-oriented is to analyze the steps required to solve the problem, and then use the function to implement these steps step by one, using a one-time call to be able. Object-oriented is the decomposition of a problem transaction into individual objects, the purpose of which is not to complete a single step, but to describe the behavior of something in the whole process of solving the problem.

For example Gobang, the process-oriented design approach is the first step in analyzing the problem:

1. Start the game,

2, sunspots go first,

3, draw the screen,

4. Judging winning or losing,

5, the turn of the white son,

6, Draw the screen,

7. Judging winning or losing,

8, return to step 2,

9, output the final result.

The problem is solved by using separate functions for each of the above steps.

  The object-oriented design is to solve the problem from another idea. The whole Gobang can be divided into:

1, black and white both sides, the behavior of the two parties is identical,

2, the Board system, responsible for drawing the screen,

3, rule system, responsible for determining such as foul, win or lose, etc.

The first Class object (Player object) is responsible for accepting user input, and informs the second class object (Checkerboard object) The change of the chess piece layout, the Checkerboard object receives the change of the chess piece to be responsible to display this kind of change on the screen, simultaneously uses the third kind of object (rule system) to determine the chess game.

    It is obvious that object-oriented is a function to divide a problem, not a step. The same is the game, the behavior in the process-oriented design scattered in the total number of steps, there is likely to be different drawing version, because the designers often consider the actual situation of a variety of simplification. In object-oriented design, the drawing can only appear in the Checkerboard object, thus guaranteeing the unification of the drawing. The unity of function guarantees the extensibility of object-oriented design. For example, I want to join the Undo function, if you want to change the process-oriented design, then from the input to the judgment to show the sequence of steps to change, even the steps between the sequence of a large-scale adjustment. If it is object-oriented, only with the change of the Board object on the line, the board system to save black and white on both sides of the game, simple backtracking can be, and the display and rule judgment is not to be taken into account, while the entire function of the object call sequence has not changed, the change is only local.

Here you can see clearly the difference between object-oriented and process-oriented. "Process oriented" is an event-centric programming idea. is to analyze the steps required to solve the problem, and then use the function to implement the write step and call it sequentially. Object-oriented is a programming idea centered on "object". The process is to analyze the steps needed to solve the problem, object-oriented is to break up the things that make up the problem into objects, abstract the object is not to complete a step, but to describe its behavior in the steps to solve the problem. The process-oriented thinking mode is the analysis synthesis, the object-oriented thinking mode is constructs. For example, the C language solves the problem by defining the data structure first and then constructing the algorithm. Instead of using the Java object-oriented approach, the object is abstracted and a "closed" environment is created, with defined data and algorithms for solving the problem. process-oriented design is more challenging, technical, object-oriented mainly in object abstraction technology, once the abstraction is complete, anyone can do the work behind. From the code-tier structure, the main difference between object-oriented and process-oriented is whether the data is stored alone or in combination with operations. Object-oriented provides the encapsulation of data, and yes, for an operation, data access becomes reliable. the process is to take coding as one thing, step by step, object-oriented is to coding as a thing, what needs to be done by the things (objects) of their own behavior to complete. Overall: Object-oriented is the abstraction of things highly. Process-oriented is a top-down programming object must first establish an abstract model, and then directly use the model on the line.

Process-oriented and object-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.