企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[TOC] ## 用布尔变量对程序加以文档说明 bad ``` if( (elementIndex<0) || (MAX_ELEMENTS<elementIndex) || (elementIndex ==lastElementIndex) ){ ... } ``` good ``` finished =(elementIndex<0) || (MAX_ELEMENTS<elementIndex) ; repeatedEntry = (elementIndex ==lastElementIndex); if(finished|| repeateEntry){ ... } ``` ## 用布尔变量来简化复杂问题的判断 bad ``` If ((document.AtEndOfStream()) And (Not inputError) ) AND ((MIN_LINES <=lineCount) And (lineCount <=MAX_LINES)) And (Not ErrorProcessing()) Then 'do someting or other End If ``` good ``` allDateRead = (document.AtEndOfStream()) And (Not inputError) legalLineCount = (MIN_LINES <=lineCount) And (lineCount <=MAX_LINES) If (allDateRead ) AND (legalLineCount) And (Not ErrorProcessing()) Then 'do someting or other End If ```