. NET Senior architect 0004 Architect's Road (3)---detailed object-oriented

Source: Internet
Author: User

detailed object-oriented programming (OOP) 3.5.1 What is Object-oriented
When it comes to programming, most of the instinctive reactions of most people may be process-oriented (OP) rather than object-oriented (OO). This phenomenon is actually very normal, change the way of thinking is needed a process, I generally summed up the reasons for its formation:
1. Direct cause
You haven't developed a habit of object-oriented analysis and problem solving. Building an object-oriented mindset requires a certain amount of time to train and figure out, so you can deliberately reinforce that awareness in your studies or specific projects. In general, after a period of time, you will feel that this is a natural thing, only the heart oo, the eyes of natural oo.
2. Historical reasons
The training we received from a young age is a process-oriented (OP) approach to analyzing problems and solving problems, especially in mathematics, most of which emphasize step-by-step solutions, and the development of computer software has always been a source of mathematics, so, logically, the process-oriented (OP) Way into software development is also a natural thing.
What is object-oriented, or talk about your opposite to the object of understanding, this is probably the software developers, especially programmers and designers when candidates, the interviewer often the most hanging on the mouth of the question. The object-oriented English is object-oriented, the translation of object-oriented into "object-oriented", I have always felt that this translation is not very accurate, because most people first saw the "object-oriented" Four words, it is difficult to literally understand what it means. Later, I looked up some relevant information, found that the computer books in Hong Kong, Macao and Taiwan are translated into "object-oriented", the translation method, I feel good, in my heart quite some obsession Yan. "Object-oriented" is a relatively accurate reflection of objects-oriented cognition and problem solving is to be carried out around the object.
Therefore, the object-oriented thinking mode is that: The software system is a set of interactive objects. A group of related objects is combined into a subsystem, and a set of subsystems continues to be combined into more complex subsystems until it is combined into the entire system.
The starting point of object-oriented approach is to simulate the way of thinking of human habits as much as possible, to abstract the content of "problem domain" into "object", so as to make the method and process of software development as close as possible to the method and process of human understanding of world problem solving.
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.    The thinking of process cognition and problem solving can be called "Process Theory", which focuses on the process steps, and the process is the core of the whole system. Object-oriented cognition and problem-solving thinking can be called "assembly theory", focusing on the abstraction and extraction of objects, and then assembling the objects as a whole. So Oo and op from the way of thinking, the starting point is still completely different.
3.5.2 OP PK OO
Let's compare the difference between OP and oo using the example of chess versus:
Red side: Kung Fu Panda Black side: The tiger Referee: Turtle Immortal
Using process-oriented (OPP) design ideas, first split the entire battle process, analysis of the two sides of the process of battle, to get the following flow:
The problem is solved by implementing each of the above steps separately using a function. Let's take a look at how object-oriented is to solve the problem, the whole chess game can abstract 3 kinds of objects:
1, chess players, responsible for chess, the two acts in line.
2, chess board, responsible for drawing the board screen.
3, the referee, responsible for determining such as eating children, fouls and win.
The relationship between the three is as follows:
The first kind of object chess player is responsible for the chess, and informs the second kind of object checkerboard the change of the chess layout, the chessboard receives the change of the pawn layout, is responsible for the drawing screen, simultaneously uses the third kind of object referee to judge the chess game.
From the above two ways of realization can be seen:
1. maintainability
Object-oriented is to divide the problem by data and function, not by processes and steps. The same is the behavior of the chessboard, in the process-oriented design scattered in a lot of steps, it is likely to appear in different drawing version, but not much like an "egg fried rice" in the eggs? In object-oriented design, the drawing can only appear in the Checkerboard object, thus guaranteeing the unification of the drawing, which is the effect of separating the eggs from the "egg fried rice".
2. Scalability
If I want to add the function of the undo, if you want to change the process-oriented design, then from the line to show to the judgment of the sequence of steps to change, even the step between the steps of a large-scale adjustment. If it is object-oriented, only with the change of the Board object on the line, the Checkerboard object saved both sides of the game, simple backtracking, minus one can be, and the display and decision is not involved, while the overall function of the various objects are not changed in order, the change is limited to the local.
deep thinking of 3.5.3 Oo
Oo thinks: A software system is a set of objects that interact.
Because human beings are very familiar with the real world, OO is to map the problem domain to the real world and try to simulate everything in the real world in an abstract way. In this way, we can use the real-world problem solving methods and processes to solve problems in the software field.
Some people say: oo eyes all objects, this sentence is still very reasonable.
What benefits does OO bring to software development? How to grasp the abstract scale of OO? This is all a problem.

. NET Senior architect 0004 Architect's Road (3)---detailed 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.