Thinking about reconstruction

I recently received a task, roughly adding an else if to a piece of code to do something. Considering that conditions may be added later, I want to refactor part of the code into a strategy. After doing most of it, I found that the business logic is more complicated than I thought. After refactoring in this way, unexpected bugs or refactoring failures may occur. So I plan to add else if to solve it.

 

The lesson of this matter is:

Consider refactoring after understanding a piece of logic very well. Restructuring hastily may produce miscalculations and more unexpected effects.

 

Finish the task first, read this piece of logic more, understand it better, and see if there is a chance to refactor it.

Record the thoughts at this time here

Guess you like

Origin blog.csdn.net/MrBack/article/details/106968412