Improved code design-refactoring

Source: Internet
Author: User

In the past few days, my task extracts a long method to make its code shorter, better understood, and better modified!

In fact, this is the term Code refactoring!

Reconstruction of local code is relatively simple, but it should be noted that you must conform to the existing architecture ideas and think within its scope.

In fact, most of the reconstruction in this way is the extraction method, or the current Code Execution Process is reconstructed based on the idea of a real business process, so that it is easy to understand, or reduce the dependencies between programs. There is an important way of thinking to do this:

1. Be good at analyzing what is the essence of things and what is the external environment of things from something.

2. Discover commonalities from many different things and abstract these commonalities (for example, for BMW and Audi, You Should abstract them into cars ).

Why do we say this, because these can bring about the need to refactor the Code:

1. reduced dependency during code writing,

2. abstract things are more reusable

 

Refactoring is to improve code design and code quality, but can it be valued and recognized by superiors or leaders? This issue is also very important. Now, the society seems to focus more on the availability of code, or the first development. How can I allow my boss to agree with your restructuring and support? The following makes sense:

"First, check whether there are problems in the current project, what problems are there, and whether these problems can be solved through reconstruction. If so, rebuild the project. Your restructuring time needs to be provided by the company, the boss won't agree because you say that the dependency is strong and the dependency is low. You must let him know through the problem. The key is that only through the problem can we get the reconstruction time and resources, and your work can be recognized. This is a very realistic situation." That is to say, find out the problem, highlight the problem, and then have the opportunity to solve the problem!
Otherwise, it is thankless!

Refer:

1. Improved code design optimization function composition http://www.cnblogs.com/technology/archive/2011/05/10/2042255.html

2. Summary of improved code http://www.cnblogs.com/technology/archive/2011/05/17/2048735.html

3. How to refactor the code http://blog.csdn.net/mikefather/article/details/6258981

4. refactoring principle http://news.csdn.net/n/20050511/21179.html this is good!

 

PS:
Calculator science is such a science: it believes that all problems can be solved through an indirection layer. -Dennis debr.pdf

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.