Embedded Development "Methodology"

1. New book in hand

insert image description here
Today I got a new book "Talking about Method" (also known as "Methodology"). The author of this book is Descartes. This book introduces how Descartes used his rationality to seek truth in various disciplines.
insert image description here

René Descartes (March 31, 1596-February 11, 1650), a famous French philosopher, mathematician, and physicist. He is also one of the founders of modern western philosophy. His philosophical thought deeply influenced the subsequent generations of Europeans and laid the foundation for European "rationalism" philosophy. Descartes is best known for his achievements as a mathematician. He invented the coordinate system, the basic tool of modern mathematics, combined geometry and algebra, and created analytic geometry.

2. Four principles of Cartesian method

insert image description here
The four principles summarized by Descartes are as follows:

The first is: I will never accept as a straight-forward anything that I have not clearly recognized. That is to say, be careful to avoid hasty judgments and preconceptions, and not to add to my judgments anything more than that which is so plainly presented to me that I cannot doubt it at all.
The second is: Divide every difficult problem I examine into as many parts as possible and necessary, so as to solve them one by one.
The third is: Carry out my thinking in order, starting from the simplest and easiest to know objects, and gradually ascending bit by bit until I know the most complicated objects; Set a sequence.
The last is: In every case, examine as thoroughly as possible, and review as widely as possible, to be sure that nothing is missed.

Analyze Descartes' four principles:
The first one: Doubt everything you don't know, and don't accept authority.
Rule 2: Break complex problems into simple ones and solve them separately.
Rule 3: Arrange the problems from simple to complex, starting with the ones that are easy to solve.
Article 4: After the problem is solved, then comprehensively test it together.

3. How to use Cartesian method in embedded design

I am an embedded engineer. How to apply the Cartesian method to embedded design to achieve the unity of knowledge and action? We absorb and evolve the four principles of Cartesian:

The core of the first principle is careful introduction . Newly introduced code needs to be reviewed and tested, even officially provided code.
At the heart of the second principle is divide and conquer . The task of breaking code down into multiple independent functions. Referred to as partition.
At the heart of the third principle is layering . Divide each task into multiple system layers, from simple to complex.
At the heart of the fourth principle is transparency . When designing the code, it is necessary to consider all-round testing of the code, improve the transparency of the code, design test scripts, and fully test the code.

3.1 Cautious introduction

Any newly introduced code needs to be reviewed and tested individually. Even the officially provided code cannot be directly integrated into the project code before independent testing is completed. Sometimes the official library will also have problems:

On April 5, 2022, the JavaScript library is-promise was updated. Since the latest version did not follow the correct ES
module standards, more than 3 million front-end projects that referenced is-promise had problems. This problem even caused the entire The JavaScript ecosystem is in disarray.

3.2 Divide
and conquer Divide and conquer is to divide the entire software into multiple tasks (modules) according to its functions. The divide and conquer strategy can decompose complex and difficult tasks into multiple simple and easy-to-achieve tasks .
Each decomposed task completes a specific function, and each task only pays attention to the functions it is responsible for, and does not pay attention to the functions of other tasks. Each task needs to include all relevant codes to complete specific functions, so that the task can run independently without relying on other tasks, and achieve high cohesion.
insert image description here
The figure below is the engineering file of a gateway project. It can be seen from the figure that the whole project adopts the "divide and conquer" strategy. We divide the whole project into multiple tasks, each task completes an independent function, and each task does not Dependent on other tasks.
insert image description here

3.3 Hierarchy
Hierarchy means that a complex software function can be horizontally divided into multiple reasonable subsystem layers, and the system layers range from simple to complex, from concrete to abstract .
Related parts of the system are grouped together in the same independent layer. The realization of the function of the upper layer needs to call the function of the lower layer and get a reply, and any two adjacent layers conform to the relationship between the client and the server. The lower layer provides services for the upper layer and returns results for the upper layer calls, that is, the functions of the lower layer serve the upper layer. The lower layer is usually responsible for completing specific operations, and the upper layer usually completes abstract business operations.
insert image description here

Layered structure rules:
1. The nth layer only depends on the n-1th layer below
. 2. The nth layer does not depend on the n+1th layer.
3. The nth layer only provides services for the n+1 layer.
4. The nth layer Using the service layering provided by the n-1 layer through the interface means abstracting a task into a level from low to high.

The figure below is the engineering file of a gateway project. It can be seen from the figure that each task adopts a hierarchical strategy. Usually, we divide the tasks into three layers. The first layer is responsible for completing operations related to processor registers, the second layer is responsible for completing operations related to control logic, and the third layer is responsible for completing operations related to business.
insert image description here
3.4 Transparency
Transparency means that the behavior of the code can be detected, and the code has no dark corners and hidden depths . Any behavior of the code can be tested, and the code does not have any unknown behavior. In other words, any internal logic of the code can be tested from the outside. During the test, we can predict the result according to the feedback of the code.

Guess you like

Origin blog.csdn.net/li_man_man_man/article/details/131712906