Reconstruction - Programming

xiaoxiao2021-03-06  60

Reconstruction - the original way of programming - "Reconstructing" The first chapter has heard of "Reconstruction-Improved Code Design", and finally opened the plan for reading this book yesterday. Before reading, I feel a little mysterious. I have some confidence in the two translators, and then read the first chapter, there is a feeling. Reconstruction is a kind of way of programming, as long as you go to program, you must spend the continuous reconstruction. This is a very natural programming method without any mysterious place. Because we can't write excellent code in one time. When adding new functions, the original program structure should be refactored if we generate an obstacle. Although I didn't know how my optimization of the code was a refactoring performance, I still use this method in my programming. The theory is called theory, because it is a spontaneous behavior, the abstract refining summary of the phenomenon. This book is to take a lot of methods from the original way of reconstructing this programming, and guide us to refactor. The first chapter after reading, my biggest feeling is. The change is very small, and it is tested after each micro change. In the example of the first chapter, after the MOVE METHOD, it is not immediately changed to a new method, but a new way to change the future method, and delegate new methods. After the test is correct, then the old method is removed, and the call point of the old method is changed to call the new method and then tested. Is it too careful? I have been directly modifying the point, and there is no step. Because it is afraid of trouble, because it is too confident. If your project is only a thousand lines of code, there may not be a problem. You can hop the modified code, and you can also ensure that all affected places. But if your project is very large, if your old method (that is, the method of moving the Move Method to a new method in a certain class) is also overloaded. Can you guarantee that all the affected places? Can you guarantee that the place I have changed? This example gives me a lot. Tiny changes plus the continuous test guarantees that the bug is introduced without reconstructing. Reconstruction is consisting of very small changes. Summarize two points of experience: 1 Reconstruction is natural, and refactoring is a universal programming method. 2 Reconstruction is strict, refactoring is a project, must be carried out according to step.

转载请注明原文地址:https://www.9cbs.com/read-112878.html

New Post(0)