Differences between process-oriented and object-oriented

Source: Internet
Author: User


Differences between process-oriented and object-oriented

Process-oriented is to analyze the steps required to solve the problem, and then use functions to implement these steps Step by step. You can call these steps one by one.

Object-oriented refers to dividing a problem transaction into various objects. The object is created not to complete a step, but to describe the behavior of a thing in the whole process of solving the problem.

For example, wuziqi,Process-orientedThe first step is to analyze the problem:

1. Start the game,
2. sunspots first,
3. Draw pictures,
4. Determine whether to win or lose,
5. It's white's turn,
6. Draw pictures,
7. Determine whether to win or lose,
8. Return to step 2,
9. output the final result.

The above steps are implemented using separate functions, and the problem is solved.

WhileObject-orientedThe design is to solve the problem from another idea.
The entire Wuzi game can be divided
1. Both sides of the black and white sides share the same behavior,
2. The checkerboard system is responsible for drawing pictures,
3. The rule system is responsible for determining such as foul and win/lose. The first type of object (Player Object) is responsible for accepting user input, and notifying the second type of object (board object) of the changes in the layout of the pawns, when the checker object receives the I change of the pawns, it is responsible for displaying this change on the screen. At the same time, it uses the Third Class Object (rule system) to determine the game board.

It can be seen that the object orientation isFunctionTo divide the problem, ratherProcedure. The same is drawing board games. Such behavior is distributed across multiple steps in the process-oriented design, and different drawing versions may appear, because the designers usually take into account the actual situation for a variety of simplification. In the object-oriented design, plotting can only appear in the chessboard object, thus ensuring the unity of drawing.

The unified functions Ensure the scalability of the object-oriented design. For example, I want to add the regret function. If I want to change the process-oriented design, I need to change the input, judgment, and display steps, even steps must be adjusted on a large scale in sequence. If it is object-oriented, you only need to modify the chessboard object. The checkerboard system saves the chess spectrum of both sides of the black and white, and simply backtrack the Board object. The display and rule judgment do not need to be taken into account, at the same time, the calling sequence of the object function is not changed, but the changes are only partial.

For another example, I want to change this wuziqi game to go game. If you are looking at process design, the rules of wuziqi are distributed in every corner of your program. If you want to change the rules, you should rewrite them. But if you are an object-oriented design, you only need to modify the rule object. Isn't the difference between wuziqi and go rules? (Of course, the size of the Board seems to be different, but do you think this is a problem? You just need to make a small change in the checker object .) The general steps of playing chess are not changed from the object-oriented perspective.

Of course, to achieve changes, only the design personnel must have sufficient experience. Using objects cannot guarantee that your program is object-oriented, A beginner or a very poor programmer may be able to face the process with a virtual object-oriented approach. The so-called object-oriented program designed in this way is difficult to have good portability and scalability.

Reprint address: http://zhidao.baidu.com/link? Url = QRjQqJLYDK5NQj11Z7r9EBNO0dCVJkBq-Dnm_2BiYLHE8y3EJL2KvK4U2k1oL6ZYisIuejqbgjpgOGqQc5uQbq

Differences between process-oriented and object-oriented

Process-oriented is to analyze the steps required to solve the problem, and then use functions to implement these steps Step by step. You can call these steps one by one.

Object-oriented refers to dividing a problem transaction into various objects. The object is created not to complete a step, but to describe the behavior of a thing in the whole process of solving the problem.

For example, wuziqi,Process-orientedThe first step is to analyze the problem:

1. Start the game,
2. sunspots first,
3. Draw pictures,
4. Determine whether to win or lose,
5. It's white's turn,
6. Draw pictures,
7. Determine whether to win or lose,
8. Return to step 2,
9. output the final result.

The above steps are implemented using separate functions, and the problem is solved.

WhileObject-orientedThe design is to solve the problem from another idea.
The entire Wuzi game can be divided
1. Both sides of the black and white sides share the same behavior,
2. The checkerboard system is responsible for drawing pictures,
3. The rule system is responsible for determining such as foul and win/lose. The first type of object (Player Object) is responsible for accepting user input, and notifying the second type of object (board object) of the changes in the layout of the pawns, when the checker object receives the I change of the pawns, it is responsible for displaying this change on the screen. At the same time, it uses the Third Class Object (rule system) to determine the game board.

It can be seen that the object orientation isFunctionTo divide the problem, ratherProcedure. The same is drawing board games. Such behavior is distributed across multiple steps in the process-oriented design, and different drawing versions may appear, because the designers usually take into account the actual situation for a variety of simplification. In the object-oriented design, plotting can only appear in the chessboard object, thus ensuring the unity of drawing.

The unified functions Ensure the scalability of the object-oriented design. For example, I want to add the regret function. If I want to change the process-oriented design, I need to change the input, judgment, and display steps, even steps must be adjusted on a large scale in sequence. If it is object-oriented, you only need to modify the chessboard object. The checkerboard system saves the chess spectrum of both sides of the black and white, and simply backtrack the Board object. The display and rule judgment do not need to be taken into account, at the same time, the calling sequence of the object function is not changed, but the changes are only partial.

For another example, I want to change this wuziqi game to go game. If you are looking at process design, the rules of wuziqi are distributed in every corner of your program. If you want to change the rules, you should rewrite them. But if you are an object-oriented design, you only need to modify the rule object. Isn't the difference between wuziqi and go rules? (Of course, the size of the Board seems to be different, but do you think this is a problem? You just need to make a small change in the checker object .) The general steps of playing chess are not changed from the object-oriented perspective.

Of course, to achieve changes, only the design personnel must have sufficient experience. Using objects cannot guarantee that your program is object-oriented, A beginner or a very poor programmer may be able to face the process with a virtual object-oriented approach. The so-called object-oriented program designed in this way is difficult to have good portability and scalability.

Original post address: http://zhidao.baidu.com/link? Url = QRjQqJLYDK5NQj11Z7r9EBNO0dCVJkBq-Dnm_2BiYLHE8y3EJL2KvK4U2k1oL6ZYisIuejqbgjpgOGqQc5uQbq

Differences between process-oriented and object-oriented

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.