Code reconstruction-Basics

Source: Internet
Author: User

You don't need to worry about code refactoring. Children's songs help you solve your worries.

 

Code refactoring should not be impetuous, and the small pace is slowly adjusted;

Code refactoring must be independent and always required;

The code is restructured first, and the architecture tends to be good.

 

Name the deduplicated long function, which has two types of long parameters;

Attach to the plot data group to simplify the conditional expression.

 

Good naming is very important and concise and effective.

 

Repeated code has a trick, and function extraction is a skill;

The parallel subclass is repeated and has a total of code base classes;

There are many similar processes, and the template method solves the problem;

Horizontal code is repeated and independent classes are called everywhere.

 

Super-long functions are not available. Reading and maintenance are worrying;

Break down the function policies, and the key lies in temporary variables;

Temporary variables are stubborn, and function objects are big moves.

 

A large number of Members are organized according to their responsibilities;

Create a small category for a single responsibility, and the composite delegation class becomes smaller.

 

There are a lot of method parameters, and parameter objects are helpful.

 

One-way modification and two-way modification;

The modification of the scattered bullet is very clear, and multiple types of changes are involved in one type of change;

Divergent changes are characteristic and a single responsibility is in violation.

 

Simplified conditional expressions and two modes of policy status.

 

 

Two classic books are recommended:

Reconstruction and Mode

Refactoring-improving the design of existing code

 

This article is based on refactoring-to improve the bad taste of code in the design of existing code.

 

(** To be continued **)

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.