C++ Classes and Objects (Zero) Process-Oriented and Object-Oriented

Table of contents

1. Process-oriented

Two, object-oriented

3. Comparison of two programming ideas

4. C and C++ 


1. Process-oriented

1. What is it?

        It is a programming idea centered on the process of solving problems. That is, first analyze the steps needed to solve the problem, and then use functions to realize these steps step by step.


2. Why?

        Process-oriented is purely the idea of ​​analyzing problems, proposing solutions, and realizing solutions, which is a natural thought when people face problems.


3. How to use it?

        That is, first analyze the steps needed to solve the problem, and then use functions to implement these steps step by step, and then use the main function to call these steps.


Two, object-oriented

1. What is it?

        It is a software development method that uses classes and objects as the core to abstract and describe the things involved in the problem.


2. Why?

        The three major characteristics of object-oriented: encapsulation, inheritance, and polymorphism improve code security, maintainability, reusability, and scalability, and help us design a low-coupling system.


3. How to use it?

Abstract the same things involved in the software development process into classes         by extracting their common attributes and behaviors (functions); when describing a specific thing, fill in specific values ​​for the attributes in the class to Define a specific object , and then solve the problem through the actions of the object. The actions involved in the object are completed by calling the functions in the class.

The three main characteristics of object-oriented:


3. Comparison of two programming ideas

1. Process-oriented

        Analyze the problem and get the solution steps --> write the function implementation steps --> call the function to solve the problem

        Analyze the steps needed to solve the problem, and then use functions to implement these steps step by step, and call them one by one when using them.


2. Object Oriented

        Analyze the transactions involved in the problem --> abstract the same transaction into a class according to the attributes and behaviors --> fill in the attributes of the specific transaction to get the object --> solve the problem through object actions (calling methods in the class)

        Construct each object involved in the problem. The purpose of establishing an object is not to complete a step, but to describe the behavior of the object in the entire problem-solving steps. The behavior between objects naturally includes all the process of solving problems.

eg. Use process-oriented and object-oriented to design food delivery system:

Process-oriented:
       pay attention to the process of ordering, receiving orders and delivering meals. Focus on the implementation of the function.

Object-oriented:
       focus on users, merchants, and riders. Pay attention to the behavior of the object, such as the behavior of the user ordering food, the behavior of the merchant receiving the order, and the behavior of the rider delivering the food (the action of the object naturally includes all the process of solving the problem.)


4. C and C++ 

        1. The C language is process-oriented , focusing on the process , analyzing the steps to solve the problem, and solving the problem step by step through function calls.

        2. C++ is based on object-oriented (it supports object-oriented and process-oriented mixed programming), focuses on objects , constructs the objects involved in the problem, and describes the behavior of the objects in the entire problem-solving steps. 

Guess you like

Origin blog.csdn.net/look_outs/article/details/131998495