More streamlined code, more detailed comments to make the project easier to maintain

Source: Internet
Author: User

More streamlined code, more detailed comments, makes the project easier to maintain, because the nature of the project is not code, it is the algorithm, it is the implementation step,

If the code is not streamlined, very bloated, long time, the specific implementation process will be memory fuzzy, code bloated, and later it will take more time to read.

Sometimes you can do it while you're writing, and don't wait until later to refactor.

A few ways to streamline refactoring:

1 Extraction Method: Extraction of common functions, can be put into some general tool class

2 Extracting variables: Especially for variables that are used in many if-else structures, you can define an empty variable and then, depending on the situation,

To assign values.

3 Cut off variables: A complex system must have a lot of objects and variables, actually thinking carefully,

Some objects and variables can be cut off without affecting the principle of high cohesion and low coupling, a single principle

Two comments, if there is not too complex logic, it does not need to be too detailed, if there are more complex logic, it is better to annotate a bit more

More streamlined code, more detailed comments to make the project easier to maintain

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.