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, the process-oriented design is the first step in the analysis of the problem: 1, start the game, 2, Sunspot first go, 3, draw the screen, 4, Judge Win and lose, 5, turn to white son, 6, draw the screen, 7, Judge Win and lose, 8, return 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 exactly the same, 2, the Board system, responsible for drawing the screen, 3, the rule system, responsible for determining such as foul, winning and losing. 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 show this change on the screen, and uses the third kind of object (rule system) to decide 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.
For example, I want to change this Gobang game to go game, if you are process-oriented design, then the rules of Gobang distributed in every corner of your program, to change is not as good as rewriting. But if you are the object-oriented design, then you only change the rules of the object can be, Gobang and go is not the difference between the rules? (Of course the size of the chessboard is not the same, but do you think this is a problem?) Just make a small change to the Checkerboard object. The approximate steps of playing chess have no change from the object-oriented perspective.
Of course, to achieve the change is only a local need to design people have enough experience, the use of objects can not guarantee that your program is object-oriented, beginners or very poor programmers are likely to object-oriented virtual process-oriented reality, so that the design of the so-called object-oriented program is difficult to have good portability and scalability.
Object-oriented and process-oriented differences