Refactoring should be aware of things

Source: Internet
Author: User

Code refactoring can read the classic "refactoring-improve the design of existing code," The following is the experience of refactoring in the work:

1, only one small step at a time, for a problem with the purpose of refactoring, modified after the test , check-in. In the process of modification in time to see the next code can be optimized or not by the way to refactor, or the spread of more and more large, eventually failed or introduced a bug

2, a small step at a time, if the modification pass or test problems, for a moment can not find the reason, you must give up the step to make any changes ( not to give up ). Do not allow half of the changes to commit, and later you will find that you can recover these steps faster to complete the refactoring. If the code structure is optimized for refactoring, and the results find that the new results are not good, discard the changes you made. ( not too mature to give up )

3, do not optimize for landscaping, to optimize for the problem, the precious time spent in the worthwhile place. If a module or function works, and you don't know how to refactor better, do not refactor and refactor from the surrounding area (the countryside surrounds the city ). Do not expect a beautiful architecture to change the code immediately into a good architecture, it must be a small step forward, progressive optimization, a little bit of improvement.

4, anytime, anywhere small reconstruction, do not expect special to set aside a few weeks to reconstruct, try not to refactor and reconstruct, even if the reconstruction is to solve the most important problem.

5. Do not add function when refactoring, ensure the reconstruction result does not change function.

6, about the reconstruction work plan, the proposed first through the code to check and mutual search, know what is the code problem, and then split up unified to reconstruct the module of each code problem, summary to the person in charge, form a list of code problems, unified in order of priority reconstruction, the specific change code first let everyone observe how to reconstruct, Then we will revise the similar problem according to the same knowledge, then make the next revision plan.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.