11.1 Refactoring Function Program

Source: Internet
Author: User

11.1 Refactoring Function Program

Refactoring is a major part of many modern development methods. In some languages, this technology also supports the integrated development environment (IDE), such as the C # Editor in Visual Studio. Most refactoring techniques are developed for object-oriented paradigms, but we will discuss them from a functional perspective.

Refactoring

Refactoring is the process of modifying the source code, improving the design, but not changing its meaning. The goal of refactoring is to make the code more readable, easier to modify or extend in the future, or to improve its structure. A simple refactoring example is renaming a method that makes the name more descriptive, and another example of converting a piece of code into a method for reuse to avoid code duplication.

With refactoring, we first write the code that works, and then make the code more "clean." The two tasks are performed separately, simplifying the test because refactoring does not affect the behavior of the application. Some of the changes are fairly simple, such as renaming (especially with tools), while others may require more thoughtful consideration.

If you change the order of two statements, will the code behave the same way? Using imperative code with side-effects, these two statements must be carefully examined, and functional programming makes the code easier to infer, so refactoring becomes easier. In this section, we'll have a few examples, but start with a functional refactoring that eliminates repetitive code.

11.1 Refactoring Function Program

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.