How to avoid reflow errors caused by modifying code during development

Many times during our development process, it is inevitable to modify the mess left by the predecessor. At this time, how can we modify the code without affecting the original function?

1. Create a new branch

Usually when we develop or modify bugs, we usually create a new branch of our own, and then merge it into the main branch when there is no problem. The specific plan will be introduced below.

2. Rewrite an interface or method

This method is the most time-consuming, and it is the most difficult for new developers to start when they first come into contact with the business. Moreover, if it is an unfamiliar business, it will definitely not affect other content at all. Of course, those who are familiar with the business can rewrite it. , but not recommended either

3. Use the overloading feature to rewrite the service layer of the interface (recommended)

As shown in the picture:
Insert image description here
Another look at this method connects 3 methods. Although there are not many, there are no comments. So how should we modify it?
Insert image description here
We can re-declare a method in the service layer and then rewrite the specific method.
Insert image description here
If it is directly in the original Modify the method. If there are many related methods, you need to modify each one. This will not only avoid affecting the original function, but also complete the modification of bugs or requirements, killing two birds with one stone.

Guess you like

Origin blog.csdn.net/weixin_52796198/article/details/131245202