软件工程(建议参考 代码大全)
代码优化
bool bFlag =true;
if(bFlag)
{
//do something
}
---------------
if(!bFlag)
{
//do something
}
---------------
优先级是先处理 异常情况,立即处理,返回错误, 不要明知道有错误,还要 一直往下走,浪费CPU,内存。
if(!bFlag)
{
//do something exception
return x;
}
if(!bFlag2)
{
//do something exception
return x;
}
if(!bFlag3)
{
//do something exception
return x;
}
//do something
原文:https://www.cnblogs.com/scotth/p/10432482.html