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