How to effectively reduce repeated code and effectively reduce repeated code

Source: Internet
Author: User

How to effectively reduce repeated code and effectively reduce repeated code

Repeated code has always been the enemy of maintainability. One of the important tasks of refactoring is to remove repeated code, effectively reducing repeated code, which can greatly improve the scalability of the software.

In Android development, duplicate code is easily generated. Because Android is a component and template-based development, every page is implemented independently using Activity or Fragment, and layout files are written in XML format, it is easy to cause code duplication, although the two pages are almost the same, they are two activities after all, so copy them one by one. Let's change it.

So how can we remove repeated code?

Click to read the full text


How to Reduce code duplication in C ++

Declare a friend function in the class, and you can just create a loop.
Int total_math;
For (int I = 0; I <9; I ++)
{
Total_math + = stu [I];
}

How does html Development implement encapsulation to reduce code duplication?

If it is. net, there is a template page function that can be used. For html, you can only use the framework. Frameset or iframe

Related Article

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.