About Refactoring (ii)

Source: Internet
Author: User

Recently in the "refactoring to improve the existing code design" This book, some sentiment to share to everyone!! This sentiment all own blind thought, said the wrong please forgive me!!

This book I have seen the 6th chapter, the first 5 chapters can be briefly summed up as: "Why Refactor?" How to Refactor? (Methods, principles of refactoring) "

The book mentions "nothing but three or three refactoring", meaning that a method, a function used 3 or more times, should be considered for refactoring.

When to refactor?

    1. When adding features: Because a feature base class may be used in multiple places, but the customer has a write demand, need to add new features, but you are not sure whether the changes in the base class will affect other function points, it should be refactored at this time.
    2. When patching errors: this is similar to the situation above, when patching this error, you cannot be sure that after the modification will cause other errors, you should refactor
    3. When reviewing code: review Code The Code is reviewed by many companies when they deliver the project (probably not by a large company, at least for the time being), because the code cannot be written by a reviewer (which should be said to be not an open person to review their own code), and may not be able to understand the functionality of some snippets , it should be reconstructed.

Why refactor? It can be said that the advantages of refactoring, where is the advantage?

    1. Improve software design: should be for the software in the initial design, there is no way to all things to think about everything, so in the subsequent development should use refactoring to compensate for the lack of software design.
    2. Make the software easier to understand: refactoring can make a computer clear what you "want him to do", more so that the latter can read it, "later"? This is someone who will ask: "Later, who is it?" "Here you can clearly tell you, a project, a function point can not always meet the needs of the late can be changed, may be you, but also may be another programmer, you can not guarantee that you have previously written the program, now come to know one of the functions of the method? At this time someone will say: "Can", (my eldest brother do not come to contradicting line no, I am not very clear about others, but for my own, it is difficult to understand, (at this time someone said it is you stupid, I can only say that I am lazy), most of my side of the programmer are lazy) feel a little bit off, we The advantage of refactoring, then, is that most of the refactoring is for the "later" to make it easier to understand the code.
    3. Help to find bugs: Because some code together may not be able to see the bug or hidden in the depths of the potential bug, we need to refactor
    4. Improve programming Speed: As you can see, it's understandable how refactoring can improve programming speed. The book said a set of written words, I use plain English it "translated" a bit, is because we initially design software when no way to design very reasonable, in the late May add new features, we will spend a lot of time in debugging, modification, debugging, modification, first we have to spend a long time to understand the system, understand the code, The duration will be dragged long, (long time the leader said to the manager: How did you get so long? Then the manager came to you and said, "a simple question has been going on for such a long time. ", you are in a bad mood, work with emotion, you quit, and a new staff to do you do not finish the problem, a vicious circle, of course, we throw out the management of the company leadership, Manager management ability, technical ability, we just stand in the programmer's perspective to see the problem)

Say so much? Some people will ask what is refactoring ah? Know the story and stay tell!!

About Refactoring (ii)

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.