The essential difference between process-oriented and object-oriented

Preface:
If you want to thoroughly understand what object-oriented, what is the process for that, or what is the difference between the two is, then it takes a little time to read up on this blog, you must have a great harvest!
 
First, the difference between object-oriented process-oriented
Process-oriented is to analyze the steps needed to resolve them, and then use the function of these steps, step by step to achieve, when used one by one in turn call on it; object-oriented is to be a problem affairs broken down into individual objects, the purpose of creating objects is not in order to complete a step, but a thing to Miao Xu behavior throughout the problem-solving steps in.
Can take the example of life to understand the process-oriented and object-oriented, such as backgammon, idea-oriented design process is the first step in problem analysis: 1, the beginning of the game, two, sunspots go first, 3, draw the screen, 4, to determine winning or losing, 5, turn albino, 6, drawing pictures, 7, determines winning or losing, 8, returns to step 2,9, and finally outputs the result. Each of the above steps to be implemented in different ways.
If the object-oriented design ideas to solve the problem. Object-oriented design is from other ideas to solve the problem. 1 whole backgammon can be divided into two sides, black and white, the behavior of the two parties are exactly the same, two, board system, responsible for drawing the picture, 3, rule system, is responsible for determining such as foul, and so winning or losing. The first class object (player object) is responsible for receiving user input, and to inform the second class object (target board) layout of the pieces change, a change in the board object receives the pieces will be responsible for this change in the screen display shown above, while use of three types of objects (system rules) for determination of the chess game.
As apparent, object-oriented function is to divide the problem, rather than a step. The same is to draw chess game, such behavior in the process-oriented design dispersed in multiple steps, it is possible to draw different versions, because usually the designer will take into account the actual situation of various simplified. The object-oriented design, the drawing may appear only in the checkerboard object, thus ensuring the unity of the drawing.
The above content is found from the Internet, that this very vivid example, I wrote down, and now you should understand the difference between right They, in fact, two words, is highly object-oriented kind of abstraction, It is a top-down process-oriented programming!
 
Second, the object-oriented features
 Before understanding of their characteristics, we should first talk about the object, the object is present in any transaction can be called real world objects, has its own unique personality
 
Attribute is used to describe a particular feature of an object. For example, a small blog height 180M, weight 70KG, where height and weight are attributes.
Object-oriented thinking is to keep everything as an object, and the object is generally composed by attributes + methods!
Static property belonging to the object side, used to describe some of the characteristics of the object, the object method belongs to the dynamic side, we give an example, Xiao Ming will run, talking, running, of these acts is the object of talk! So for the dynamic side, we have properties and methods are called members of this object!
Class: An object with the same attribute are referred to as a class is an abstract concept. Such as "man" is a class period there are some names, such as Xiao Ming, red, Linda, etc. These are objects, like the equivalent of a mold, he defines common features and functions of all the objects it contains, a class of objects is instantiated, Xiao Ming is one instantiation! When we do the procedure, often want a variable instantiation, it is the principle! We generally do when the program generally do not like the name, such as when we called the Little Ming, do not shout "Man, you are doing it!" But that is "Xiao Ming, you are doing it!"
Object-oriented has three characteristics, namely, encapsulation, inheritance and polymorphism, here small does not give much explanation, because the blog will specifically behind the summary!
 
Third, process-oriented and object-oriented advantages and disadvantages
A lot of information on all theoretical knowledge of a group of hard to understand, the whole of the small series have a big head, and later found a good article, write great, easy to understand, do not want to see is immune!
Write out a program with a process-oriented approach is a fried rice, and written with object-oriented programming is a rice bowl. The so-called rice bowl, Beijing called the Rice Bowl, Northeast called risotto, Guangdong called head rice dish, is a bowl of white rice in a covered dish and pour the above, what food do you like, what you pour dish. I think this analogy is quite apt.
Details fried rice production, I do not know, because I'm not a cook, will not cook, but the last one process is certainly the rice and egg mix and stir well. Rice bowl does, it is to cover the rice and vegetables are good, if you want to do a braised pork rice bowl, pour a Pork give you; if you want a green pepper potato rice bowl, pouring give a green pepper potato silk copies.
Benefits fried rice is tasty uniform, tastes sweet. If you happen to do not eat eggs, only eat vegetables, then the only way is to pour all the re-do a vegetable fried rice. Rice bowl not so much trouble, you just need to cover the above dishes pulled out, the replacement of a covered dish on it. The disadvantage is the rice bowl of tasty uneven, it may not be so fragrant fried rice.
In the end is good fried rice or rice bowl is good? In fact, these problems are difficult to answer, than a non-down level, then it is necessary to set a scene, or can only be said to be their own merits. If we are not gourmet, not so much about, so from the perspective of the restaurant, then do the rice bowl is clearly more advantageous than the fried rice, he can be combined in any number of combinations out, and will not be wasted.
Benefit rice bowl is the "food" the "rice" separation, thereby increasing the flexibility in the production of rice bowl. Rice satisfied with the change of rice, vegetables are not satisfied with changing dishes. In technical terms of software engineering is the "maintainability" is better, "rice" and "food" coupling is relatively low. The fried rice "egg", "rice" mix together, want to change the "egg", "rice" in any of a very difficult, a high degree of coupling, so that "maintainable" relatively poor. One goal is to software engineering maintainability, serviceability, mainly in three aspects: understandability, testability and modifiability. One of the benefits of object-oriented is significantly improved maintainability of software systems.
  
Read this article, a simple sum up!
Process-oriented

  Advantages: performance than object-oriented, because of the need to instantiate the class when called, the overhead is relatively large, more consumption of resources; such as microcontrollers, embedded development, Linux / Unix and other commonly used process-oriented development, the performance is the most important factor.
  Cons: no object-oriented and easy to maintain, easy to reuse, easy to expand

Object-Oriented

  Advantages: easy to maintain and reuse, easy to expand, since there are object-oriented encapsulation, inheritance, polymorphism characteristic, low coupling system can be designed to make the system more flexible and easier to maintain 
  drawbacks: performance is lower than the process-oriented
- ---------------
Disclaimer: This article is CSDN blogger "fourteen _ Li 'original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
Original link: https: //blog.csdn.net/jerry11112/article/details/79027834

Guess you like

Origin www.cnblogs.com/-dashuai/p/11781063.html