Java Fundamentals Hardening 20: Object-oriented and process-oriented thought comparison

Source: Internet
Author: User

The difference between object-oriented and process-oriented

1. Compared with object-oriented programming, often is the process-oriented programming idea, in fact, I understand that the two do not conflict, because the object-oriented programming also must use the process-oriented thinking to achieve the specific function, so I think, the difference between the two different thinking realm, Process-oriented thinking is like an employee thinking about the problem, he only care about his work to complete the steps, and the object-oriented thinking like a company's boss, he should consider the overall layout of the company, the responsibilities of various departments, and coordination of work, the direction of the company's development, and specific work, For example, the front desk reception customer process, he does not need to consider personally, but every day of the company's specific details of the work is the formation of the entire company's operation, both are linked.

2. Let's analyze it in a specific case:

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.

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), drawing the screen,

(4), judging winning or losing,

(5), the turn of the white son,

(6), drawing 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.

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.

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), board system, responsible for drawing the screen,

(3), rules 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 show this change on the screen, and uses the third kind of object (rule system) to decide the chess game.

For a novice, want to put the object-oriented thinking in the development of the use of the easy, is not a simple thing, has been said object-oriented is a kind of thought, that he must be after a long period of edification and practice, strict focus is the process of brainwashing, accompanied by the accumulation of development experience and work on the temper, Often the object-oriented understanding of the degree will be different, so the object is more like an art, you need to practice for a long time.

Java Fundamentals Hardening 20: Object-oriented and process-oriented thought comparison

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.