Understand the process
First, we need to understand how the previous system worked. We need to know how the whole process from compilation, testing and deployment to receiving user requests works.
Because this is a core service, and I just came here for a year, I really don't know how it works, especially since the whole system has added many extra functions and patches over the years, and it is difficult to understand just by looking at the code. Therefore, we need to understand the processes and rules, and then build new processes and rules based on these processes and rules.
Design and discussion
The reason for refactoring this service is that when we want to add new functions, the code architecture of the previous system cannot be well extended. It will be painful to develop new functions in the future, because we have to reconstruct a lot of things.
So what we really need is to fix the architecture. It is really difficult to design a new architecture. We need to ask ourselves many questions, such as, "What will happen?" "Why?" "Why not?" We hope that the new architecture can solve the "future" problem and provide backward compatibility. To this end, we discussed about a month, and discussed the technology stack and process of each major function.
Understand the basics
When translating the process and design into code, I realized that we must have a real understanding of the basics. At first, I didn't really understand the working principle of higher-order functions. I feel confused when I read the code. Why do functions always take a function as a parameter and then return a function? But thanks to Google, I finally understand now.
Never ignore testing.
When rebuilding this service, we conducted at least three tests before releasing it to the production environment: unit test, integration test and load test.
In all these types of tests, unit tests are very small tests. IT training/discovery Some people seem to underestimate the importance of unit testing because it is only a unit and a small function. However, when rebuilding this new service, I realized the importance of unit testing.