Part of the code in several functional modules is common. If you want to modify one of the functions, you need to modify the common code. How to avoid damaging other functions when you are not sure which functions reference this code?
天蓬老师2017-05-16 13:10:42
Add a mark judgment at the function entrance. If the mark is true, follow the logic you wrote yourself. Otherwise, the original logic will remain unchanged. Examples are as follows:
default() original, newFunc() new, main() public calling part
main()
{
if ($flag) {
NewFunc();
}
else
Default();
}
或者直接修改default()
default($flag){
if ($flag) {
你改的逻辑
}
else
原来的
}
}
This is the simplest modification. . .
大家讲道理2017-05-16 13:10:42
In this case, then this method is not public
So, change this method, according to the actual situation,
Add parameters, judge by parameters
Re-differentiate the business logic, split the original method, and recombine it
曾经蜡笔没有小新2017-05-16 13:10:42
Write the "public code" as "public class", and then change the organizational structure to the "mediator" model to reduce the coupling between the "public class" and other classes. Inherit the "public class" where changes are needed, and make modifications. part