And compare the difference between the merits of object-oriented and process-oriented Detailed

When the previous object-oriented this course, I was not particularly aware of this.

But now we found that the design of object-oriented and process-oriented thinking is very important

1. Object-oriented and process-oriented What is the difference?

Object-oriented programming and design process-oriented programming is the difference between the actual different ways to solve the problem.

First explanation for the process, you have to analyze the steps to solve the problem, then use the function to implement these steps, step by step, when a solution is to call a function.

Object-oriented, first of all you need to know the concept of the object.

The object is a specific instance of the class, such as human Joe Smith, John Doe is an object of the class, they have their own unique personality.

 Object-oriented, see the name which is focused on the object. When solving a problem, object-oriented concepts put things into abstract objects, that is the question which objects inside, and then to set this object properties and methods, and then let each object to implement its own method, the problem is resolved .

Do not worry do not understand, for example you will understand, do not understand the immune ^ _ ^

Facing the problem:   refrigerator which put dirty clothes, how clean?

 

   Process-oriented:

                    1 performs its detergent method;

       2. The method of performing discharge detergent

                    3 performs a method adding water;

                    5  execution put clothes, laundry methods;

                     6 performs cleaning method;

                   7.  perform the drying method;

---------- solve the problem split into one method, the object is not to call. Solve the problem by doing one method.       

   Object-Oriented: Let me put forward a washing machine objects and human subjects 

 

   Washing machine: add some properties and methods Cleaning method The cleaning method and drying method by: Method and detergent added water method              

 

   Then people . And detergent al . Add water to the washing machine . Laundry washing machine . Cleaning the washing machine . Drying    

 

---------- Also solve the problem first abstract object, and then to solve the problem by way of the implementation of the method of the object.   

 

On the advantages and disadvantages of both, according to your need to judge. And can not be generalized

Online a lot about both the advantages and disadvantages, I think the most vivid interpretation is more fried rice and rice bowl

Fried rice:

 

 

 

Rice bowl:

 

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", "food" separation, thereby increasing the flexibility of making 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.

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

 

Guess you like

Origin www.cnblogs.com/mch5201314/p/11564312.html